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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to clean Temp and Temporary Internet files

Status
Not open for further replies.

Keithc71

MIS
Dec 3, 2006
13
US
Looking for a way to cleanup Temp and Temporary Internet Files from within local settings for multiple profiles at user logon? Can this be done?
 
Do a search in this forum.
scope: Just My Forums

I just did a search for "temporary internet files" and found several similar posts with examples

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
I suggest it may be better to do this with a global Shutdown script rather than at Startup. Also, you won't need to worry about TIF's if you open 'Internet Explorer', select 'Tools > Options' then, on the 'Advanced Tab', tick the checkbox labelled 'Empty Temporary Internet Files folder when browser is closed'.

I always re-direct TEMP and TMP files by changing the temporary environment variable (for both user- and system-created temporary files) to point to a folder I create called 'Temp in the root of C:.

To do this, select 'Start > Settings > Control Panel > System' then, on the 'Advanced' tab, click on the 'Environment Variables' button. In both upper and lower areas, change the location for TEMP and TMP files to point to 'C:\Temp'. Note that you have to amend the upper area for each profile on the PC as this is a 'per user' setting.

My Shutdown script looks something like this:

Code:
Const oSrc = "C:\Temp"
Dim FSO
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
'Delete the folder (forcibly, to handle read-only attributes) then re-create it
FSO.DeleteFolder oSrc,True
FSO.CreateFolder oSrc

Set FSO = Nothing
WScript.Quit()

To use it in XP Pro, copy/paste the code above into Notepad then save it as something like 'DeleteTemp' to 'C:\WINDOWS\System32\GroupPolicy\Machine\Scripts\Shutdown'. (You can save it anywhere but this location just makes it easier for the Group Policy Editor to find.)

Click 'Start > Run' and enter 'gpedit.msc'. In the Group Policy Editor, expand 'Windows Settings' in the 'Computer Configuration' section then click on 'Scripts (Startup/Shutdown)' then, in the right-hand pane, click 'Shutdown'.

In the dialog that appears, click on the 'Add' button then 'Browse' to and select your shutdown script. Apply/OK your way back out of the Group Policy Editor and you're done.

Hope this helps...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top