0% found this document useful (0 votes)
35 views1 page

Delete Temp and Prefetch Files in Windows

The document outlines a script for removing temporary files from various locations on a Windows system, including the Windows Temp, Prefetch, and a specific user's AppData emp folder. It uses PowerShell commands to delete all items within these directories. A success message is displayed upon completion of the file removal process.

Uploaded by

siyire4156
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views1 page

Delete Temp and Prefetch Files in Windows

The document outlines a script for removing temporary files from various locations on a Windows system, including the Windows Temp, Prefetch, and a specific user's AppData emp folder. It uses PowerShell commands to delete all items within these directories. A success message is displayed upon completion of the file removal process.

Uploaded by

siyire4156
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#2# Remove Temp files from various locations

write-Host "Erasing temporary files from various locations" -ForegroundColor Yellow

# Specify the path where temporary files are stored in the Windows Temp folder
$Path1 = 'C' + ':\Windows\Temp'

# Remove all items (files and directories) from the Windows Temp folder
Get-ChildItem $Path1 -Force -Recurse -ErrorAction SilentlyContinue | Remove-Item -
Recurse -Force -ErrorAction SilentlyContinue

# Specify the path where temporary files are stored in the Windows Prefetch folder
$Path2 = 'C' + ':\Windows\Prefetch'

# Specify the path where temporary files are stored in the user's AppData\Local\
Temp folder
$Path3 = 'C' + ':\Users\Mayur Jaunjalkar\AppData\Local\Temp'

# Remove all items (files and directories) from the specified user's Temp folder
Get-ChildItem $Path4 -Force -Recurse -ErrorAction SilentlyContinue | Remove-Item -
Recurse -Force -ErrorAction SilentlyContinue

# Display a success message


write-Host "removed all the temp files successfully" -ForegroundColor Green

You might also like