HOME
TOPICS
SEARCH
ABOUT ME
M AIL

 
  technofile
Al Fasoldt's reviews and commentaries, continuously available online since 1983

Simple batch file empties Temp folder without user interaction


Sept. 24, 2000

By Al Fasoldt
Copyright ©2000, Al Fasoldt
Copyright ©2000, The Syracuse Newspapers

   Here is a quick way to empty the Temp folder. Run this batch file from Windows (double click on it or make a shortcut, etc.) just BEFORE you shut the computer down. (But NOT WHEN YOU ARE INSTALLING ANYTHING.)
   I'm not responsible if this does crazy things to your files. If you run it ONLY at shutdown, you should be fine.
   This method avoids the interaction required in the batch file I wrote a few weeks ago. (No, I didn't like that either.) It uses the variable called WINDIR, part of the environment (a sort of scratchpad in memory) of Windows.
   It's a batch file, so create it in Notepad, save it in the Windows folder as a file called CLEAN.BAT. SEE THE NOTE BELOW BEFORE YOU SAVE IT. The double colons are OK. (Paste the code into Notepad and save yourself some trouble.)
   
   PLEASE NOTE: Notepad insists on saving files with a TXT extension (such as MYFILE.TXT) EVEN IF YOU DON'T TYPE "TXT" AS THE EXTENSION OF THE FILENAME. This is very bad news for batch-file creation. To get around this, put the filename in quotes in the text-entry line when you save the file the first time. In other words, you would type in "CLEAN.BAT" using quotes just like that the first time you save the file in Notepad. You MUST do this.
   
    Copy everything between the two rows of asterisks.
   
   
******************************
:: Batch file starts here.

@echo off
goto start

:: clean.bat
:: Sept. 20, 2000.
:: Run ONLY at shutdown.
:: Windows 95, 98 and 98 SE only.
:: Not tested under any other version of Windows.

:start
if not exist %WINDIR%\temp\nul goto NoCanDo
deltree /y %WINDIR%\temp
md %windir%\temp
goto end
:NoCanDo
cls
echo Unable to locate Temp folder.
:end 

:: End of batch file.

        

   
******************************