What scripts do you use to clean up hard drive space on your Windows machines?
I’m exploring the automating of freeing up hard drive space on our Windows pcs using Kace SMA (k1000) scripting. Are there scripts any of you have used yourself or would recommend to one looking to free up HD space on remote (kace agent) machines?
Thanks for your time.
Answers (3)
I do something similar, but use a GPO. I use the Shutdown event for computer and LogOff event for user so I do not clear any temp files in use:
Under Computer -> Policy -> Windows Settings -> Scripts I have a Shutdown.bat script
del /q "C:\Windows\Temp\*"
FOR /D %%p IN ("C:\Windows\Temp\*.*") DO rmdir "%%p" /s /q
Under User -> Policy -> Windows Settings -> Logoff I have a Logoff.bat script
del /q "%localappdata%\Temp\*"
FOR /D %%p IN ("%localappdata%\Temp\*.*") DO rmdir "%%p" /s /q
CMD.exe /c "ECHO Y|chkdsk c: /f"(You need the ECHO Y to tell the chkdsk command Yes to perform the check on the next reboot)