Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ramifications of deleting temp files at shutdown/startup? 1

Status
Not open for further replies.

mtktech

MIS
Aug 11, 2000
35
US
I'm considering setting up workstations to process a bat file that deletes temp files on shutdown using script policies. The only problem I can forsee is deleting temp files from a program that you are installing. I would like to delete the directory "%userprofile%\local settings\temp". If your installing a program, and it rights some files to this directory then you have to reboot and those files get deleted, your program won't be able to finish installing.

Does that sound right? If so, I won't bother with deleting temp files at startup/shutdown. :)
 
In this thread bcastner showed how to set up something called a 'sageset'. This is a set of parameters for cleanmgr.exe, the disk cleanup tool. If you follow his instructions you can make a sageset that just deletes temp files and I'm sure that you can set up some additional scheduling for this to run transparently at system startup, even if it's just copying a shortcut to the startup folder.

File deletion will then be handled by Windows' own routines which should - I assume - avoid deleting anything that you shouldn't delete. Assumption is the mother of all muck-ups though, so you may want to test it on a single machine by installing some software that requires a re-boot and seeing whether it works.

Why do you want temp files auto-deleted anyway? Are you desparately short of space or is it a security concern?

Nelviticus
 
I currently use cleanmgr with the sageset switch to do some disk cleanup. The temp directory I listed above does not get deleted with cleanmgr. Space isn't an issue, I guess its more of personal preference. I just like to keep things clean. :)

I may need to just test it out on a few programs.
 
Unless these are programs download and run directly from the internet, it is rare (very rare) for them to use other than the TEMP directories shown by a command line listing of your path:

Start, Run, cmd
set

Even in this instance you can control it by setting the Environmental settings for TEMP and TMP under System Properties, Advanced, Environmental Variables in the "top" box away from the user profile and to a non-conflicting folder you create with similar TEMP variables in the "bottom" box. I hope that makes sense, but you usually have at least 3 and often more temporary storage location environomental variables, and you want to leave the defaults alone in the "bottom" box.

Having said all that, now you want to write a .bat or .cmd file to delete the files in each directory you have identified in the "top" box. You want to use the XP scheduler to do this at Startup, rather than at Logon. Use the standard DOS syntax for the DEL /q command with full pathing.

Now having said all of that, here is a terrific freeware tool to use instead of sageset as a directable solution for any Folder you point it to:
Read the FAQ, it is perfectly batchable.

Let me end with a note: other than an instance of a download of an installation file that you specify to "Open" or "Run" rather than as a pure download, you should be perfectly safe scheduling the cleanup you have planned. One reason is that the Run key used by InstallShield and MSI installations has precedence over your batch file in the run order of things on your system.

Best wishes,
Bill Castner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top