How to Delete Windows XP temporary files from command line / Batch script to Delete Windows temp files on every system restart

Thursday, 23rd August 2012

In case you need to DELete Windows temporary files directory to save some free space on an old PC or (group of PCs) in a raw you might prefer to use this CLI command lines:

DEL /F /S /Q %TEMP%
DEL /f /q /s "%SYSTEMDRIVE%Documents and SettingsLocalServiceCookies*.*"
DEL /f /q /s "%SYSTEMDRIVE%%HOMEPATH%Cookies*.*"
DEL /f /q /s "%SYSTEMDRIVE%Documents and SettingsLocalServiceLocal SettingsTemp*.*"
DEL /f /q /s "%SYSTEMDRIVE%Documents and SettingsNetworkServiceLocal SettingsTemp*.*"
DEL /f /q /s "%SYSTEMDRIVE%Documents and SettingsDefault UserLocal SettingsTemp*.*"
DEL /f /q /s "%SYSTEMDRIVE%%HOMEPATH%Local SettingsTemp*.*"
DEL /f /q /s "%WINDIR%Temp*.*"
DEL /f /q /s "%TEMP%*.*"
DEL /f /q /s "%SYSTEMDRIVE%Documents and SettingsLocalServiceLocal SettingsTemporary Internet Files*.*"
DEL /f /q /s "%SYSTEMDRIVE%%HOMEPATH%Local SettingsTemporary Internet Files*.*"
RD /q /s %TEMP%
RD /q /s %WINDIR%Temp
RD /q /s "%SYSTEMDRIVE%Documents and SettingsDefault UserLocal SettingsTemp"
RD /q /s "%SYSTEMDRIVE%Documents and SettingsLocalServiceLocal SettingsTemp"
RD /q /s "%SYSTEMDRIVE%Documents and SettingsDefault UserLocal SettingsTemp"
RD /q /s "%SYSTEMDRIVE%%HOMEPATH%Local SettingsTemp"

Another helpful thing for MS Windows users is cleaning up Windows Tempory Files on every system restart (reboot); doing so is possible by setting below’s short batch script to exec on every system boot:

@ECHO OFF
IF NOT %temp% == %tmp% GOTO both_
GOTO single
:both
DEL %temp%*.* /F /S /Q
DEL %tmp%*.* /F /S /Q
CLS
ECHO Deleted all files in the TEMP folder: %temp%
ECHO Deleted all files in the TMP folder: %tmp%
GOTO end
:single
DEL %temp%*.* /F /S /Q
CLS
ECHO Deleted all files in the TEMP folder: %temp%
:end

You can download the script clean_windows_temp_files_on_win_start.com here . The script is great tool for Windows administrators of Win Domain Controllers or University / educational M$ Windows based networks, where PC security is at high risk. Setting the script to run on even “non-critical” home PCs is a great idea as it can save you a lot of troubles with SpyWare, Malware Viruses and other Windows targetted “Bad-Wares” 🙂

Cheers 🙂

Share this on:

More helpful Articles

Download PDFDownload PDF

Tags: , , , , ,

Leave a Reply

CommentLuv badge