microsoft_windows:cleantemp
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | microsoft_windows:cleantemp [2022/05/07 19:49] – rodolico | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Clean Temp Files ====== | ||
+ | This is a manual procedure. I did **not** want to have it automatic since there is a good chance of failure. | ||
+ | |||
+ | This will show you how much disk space is used a part of the system, then the second command will allow you to delete it. //You must make sure no one is logged into the server// before running this. | ||
+ | |||
+ | <code powershell> | ||
+ | # This gets the space used for each item, in gigabytes | ||
+ | " | ||
+ | "Users Temp {0:N2} GB" -f ((Get-ChildItem -force -recurse C: | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | |||
+ | # the following actually does the deletion. However, the -WhatIf says "show me what you'd do", so | ||
+ | # you must remove that before it will actually clean up. | ||
+ | Get-ChildItem –Path | ||
+ | Get-ChildItem -Path " | ||
+ | Get-ChildItem -Path " | ||
+ | Get-ChildItem -Path " | ||
+ | Get-ChildItem -Path " | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ====== Clean Temp Directory ====== | ||
+ | |||
+ | Any windows machine will fill up with temporary files, and many applications do not clean up after themselves very well. The following batch file will delete all files older than 30 days in your personal temp folder. | ||
+ | |||
+ | <code bat cleantemp.bat> | ||
+ | echo off | ||
+ | echo " | ||
+ | forfiles /p %temp% /s /m *.* /D -30 /C "cmd /c echo @PATH" 2>nul || goto NoFiles | ||
+ | choice /m "Ready to delete these files? " /t 10 /d n | ||
+ | if ErrorLevel 2 goto No | ||
+ | if errorlevel 1 goto Yes | ||
+ | goto End | ||
+ | |||
+ | :Nofiles | ||
+ | echo No files found | ||
+ | goto end | ||
+ | |||
+ | :No | ||
+ | echo Aborted | ||
+ | goto End | ||
+ | |||
+ | :Yes | ||
+ | forfiles /p %temp% /s /m *.* /D -30 /C "cmd /c del @PATH" | ||
+ | echo Files Deleted | ||
+ | |||
+ | :end | ||
+ | </ | ||
+ | |||
+ | ===== Windows System Temp Folder ===== | ||
+ | |||
+ | Windows has no way to easily clean up the c: | ||
+ | |||
+ | You can remove any files in the Windows Temp folder (c: | ||
+ | < | ||
+ | Get-ChildItem –Path | ||
+ | </ | ||
+ | the -WhatIf at the end of that command says "do a dry run", ie show what would happen, but don't actually do it. Remove that in order to actually clean up the system (remove the files). | ||
+ | |||
+ | To run this, find PowerShell and open as Administrator, | ||
+ | |||
+ | ===== Links ===== | ||
+ | * [https:// | ||
+ | * http:// |
microsoft_windows/cleantemp.txt · Last modified: 2022/11/14 03:15 by rodolico