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!

Empty "TEMP" folder for all users in XP/2003 6

Status
Not open for further replies.

mkirkaero

IS-IT--Management
Jul 30, 2003
27
US
I need to clean out the temp folder located at: c:\documents and settings\USERNAME\local settings\TEMP
for each user with a profile on the computer

All users profiles at once if possible.

I tried a batch file with c:\documents and settings\%username%\local settings\temp

It recognized the user that was running it but not the others.

I have temp files from an old app that could confict with temp files from the upgrade.
If cannot do it with a batch or programatically I have to go to each users temp folder and empty it.
 
I did a web search and found this other global variable (didnt know it existed): "%Userprofile%"

So you might try using this variable rather than the "%username%" in your batch file and see if it does any better.
 
Any 'user' variable will only point to the current user (which is why 'It recognized the user that was running it but not the others').

I don't understand this:-
'I have temp files from an old app that could confict with temp files from the upgrade'

If the install/upgrade app writes files to the temp folder, it will overwrite any that are there if same name. Also - surely you'll just be running the upgrade once from an Adminstrative user?

 
Yes, you are about the temp files overwriting.
A tech from the ERP software company had suggested this could happen, after I left this post I realized this made no sense so I called back and confirmed he did not know what he was talking about.


My other reason behind trying this batch file is to have a cleaner.
The temp files that are created are good sized and over a period of a couple monthes they can get to be "gigs" in all of the users temp folders combined.
Because it is just a Terminal Server there is not alot of space and I have to clean the temp folders by hand.

 
you could run a batch that would find all the files...
they have an extension i imagine.

or setup a batch file that runs when users log off....
that way they do their disrty washing before leaving .

Aftertaf (david)
MCSA 2003
 
bill...
did you write windows??

just wondering, cos you seem to have amassed a ridiculous amount of savoirfaire on 2000/XP...
:)
respect, man

Aftertaf (david)
MCSA 2003
 
...ridiculous amount...." is right.

Best regards,
Bill Castner
 

Disk Cleanup uses the the following Registry Key in determining which location it will delete temporary files from.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files

It uses the following Value in the above key to determine how old those files must be before it will delete them.

"LastAccess". The Default value is 7 days.



Disk Cleanup (and other programs) also use the Environmental Variables to determine the location of the TEMP folder it will delete the files from. The Default folder is -

User Variables for usernamexxxx
%USERPROFILE%\Local Settings\Temp

The above lists user environment variables (such as a path where files are located) that are defined by you or by programs.


The alternative location if the "User Variables for usernamexxxx" are removed is -

System Variables.
%SystemRoot%\TEMP

This lists system environment variables defined by Windows, which are the same no matter who is logged on to the computer.


You must be logged on as a member of the Administrators group to change values or add new variables.



My conclusion therefore is that in order to delete everyones temp files (in one action) you must select the "System Variables" and remove every "User Variables for usernamexxxx" (that apply to %USERPROFILE%\Local Settings\Temp) in the Environmental Variables, thus forcing users to store their .temp (or .tmp) files in %SystemRoot%\TEMP rather than %USERPROFILE%\Local Settings\Temp.

Further, to delete files less than a week old you must remove or edit the "LastAccess" value of the above Registry Key.

 
When you figure out how to clear the temp folder, do yourself a favor and warn all users via email about two weeks beforehand that you are doing this.

Some users (mostly N00bs) intentionally store things in the TEMP folder and get really irate when they find out that IT made them disappear.
 
linney,

I suppose I am missing something critical, but my suggestion about using Sagesets, the cleanmgr.exe, and Sagerun:xx with scheduled tasks was squarely aimed at the Terminal Server, where there appeared to be the issue.

To the Scheduled Tasks as local NT authority or local to the server Administrator user, all the user folders can be cleaned.

As an amplification on the client side, there were some valuable additions to scheduled tasks with service pack 2. You could schedule a series of identical jobs, and assign permissions to each user when the logon, logoff, etc but would be active using cleanmfr with an appopriate /Scanset:xx value for each user logon.

Reference:
The schedulable options available under disk cleanup, the use of Sagesets, and their use in scheduled tasks is not as well known as it should be.
 
My comments, as usual, are from experience on small networks with just a few workstations joined together. I probably wouldn't recognize a Terminal Server even if I fell over one.

Nevertheless I thought it helpful to point out some considerations for us lesser mortals who come this way.

I also wonder if the "LastAccess" value might have similar ramifications on a Server as it does on a Workstation?
 
I was suddenly hit in the head with a cheesy easy idea and it works like a champ.

At the end of my login.bat file i put this:

@echo off
c:
cd c:\documents and settings\%username%\local settings\temp
del /q /s /f *.*

THANK YOU ALL FOR YOUR HELP.

BCASTNER, Do you sleep? You are everywhere in Tek Tips :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top