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

Log on/off script for cleaning Temp Internet Files

Status
Not open for further replies.

chrisukcov

IS-IT--Management
Jun 25, 2001
111
GB
Hi,

Im looking for a script/bat file to run to clean down the current user profile temp files like:

- Temporary Internet Files
- History
- Cookies
- Temp

All under c:\documents and settings\%username%\local settings

Theres loads of sites with help on this but none that actually work correctly. Can anyone help with a script or a link to a script for me ?

Cheers all.

Chris

 
This script will clear the temp Internet files every time the bowser is closed.

I can't take credit for it, this is from Microsoft's Tweakomatic.

Code:
HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache"
objReg.CreateKey HKEY_CURRENT_USER, strKeyPath
ValueName = "Persistent"
dwValue = 1
objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName, dwValue

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
You should also check out the power toy call TweakUI. The paranoia tab has more of what you were looking for.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Works a treat - cheers Mark....

wouldnt think something like that would be so hard to find!!

Hey ho

Chris
 
Works when admins/domain admins log in but not joe bloggs user, and when try to run manually says havent got rights to apply script basically.... can i enter an account in GP to force it to use admin rights on install?

Chris
 
Not sure if setting impersonation will help but give this a try.

Code:
HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache"
objReg.CreateKey HKEY_CURRENT_USER, strKeyPath
ValueName = "Persistent"
dwValue = 1
objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName, dwValue

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
'==========================================================================
'
' NAME: EmptyTempInternetFilesonExit.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: ' DATE : 6/3/2004
'
' COMMENT: <comment>
'
'==========================================================================

Dim WshShell, scomputername
Set WshShell = WScript.CreateObject("WScript.Shell")
Set oNetwork = WScript.CreateObject( "WScript.Network" )

srunme = runas /netonly /user:eek:rbit\administrator "regedit /s \\reporting\sysvol\orbit.org.uk\scripts\EmptyTempIntFiles.reg"

WshShell.Run srunme
WScript.Sleep 500
WshShell.Sendkeys "mypassword" & chr(13)


Is there anything in the above that would make it not work ?


If i do:

Start>Run>cmd (ent)

runas /netonly /user:eek:rbit\administrator "regedit /s \\reporting\sysvol\orbit.org.uk\scripts\EmptyTempIntFiles.reg"

then enter my p/word it works??

Chris
 
Gosh, I forgot I had made this script before. :)

Use this instead:
WshShell.Sendkeys "mypassword"
WshShell.Sendkeys "{ENTER}"


If you don't want to reference a reg file here is that same script from my archives:

Code:
'==========================================================================
'
' NAME: EmptyTempInternetFilesonExit.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 6/3/2004
'
' COMMENT: <comment>
'
'==========================================================================

Dim path
Set WSHShell = Wscript.CreateObject("WScript.Shell")

path = "HKCU\Software\Microsoft\Windows\"

WSHShell.RegWrite path & "ShellNoRoam\MUICache\@inetcplc.dll,-4750","Empty Temporary Internet Files folder when browser is closed","REG_SZ"

WSHShell.RegWrite path & "CurrentVersion\Internet Settings\Cache\Persistent","0","REG_DWORD"

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Tried that script of yours earlier from other post - script works fine but its getting it to run from Group Policy>Logon script section, standard users cant run this script....

Im getting brain drain off this now :( siighhh

Tried multiple things running a vbs to use the run as command but things just arnt working!

Thanks for all your help... its just getting this thing to run as admin!
C
Chris
 
You could try enumerating through all users in the HKUsers and setting this.

Here is another script I made that shows how to enumerate through registry keys.

Code:
'Registry edit script 

'By Mark MacLachlan, The Spider's Parlor

'(c)2004 All rights Reserved

'Modifies the registry to change exchange server names.

'Notes:  Modify the path and server variables for your environment.

 

On Error Resume Next


const HKEY_CURRENT_USER = &H80000001
 

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_

".\root\default:StdRegProv")

Set StdOut = WScript.StdOut

strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"

oReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubKeys


For Each subkey In arrSubKeys

      expStrKeyPath = strKeyPath & subkey & "\"

      oReg.EnumKey HKEY_CURRENT_USER, expStrKeyPath, arr2SubKeys

        For Each subkey2 In arr2SubKeys
  
            expStrKeyPath2 = expStrKeyPath & subkey2


	    If Right(expStrKeyPath2,32) = "13dbb0c8aa05101a9bb000aa002fc45a" Then
               Dim Path

               Path = "HKCU\" & expStrKeyPath2 & "\"

	       Set WSHShell = Wscript.CreateObject("WScript.Shell")

	       ServerName = "ACEMAIL"

               'this fills the sub key with the value of new server and specifies that it is a regular string

	       KeyExist = WSHShell.RegRead(path & "001e6608")

                   If KeyExist = ServerName Then

                        Wscript.Quit

                   ElseIf Ucase(KeyExist) <> "R2D2" Then

	                 MsgBox "Unexpected Exchange Settings.  Please contact the help desk"

                         Wscript.Quit

		   ElseIf Ucase(KeyExist) = "R2D2" Then

	            WSHShell.RegWrite path & "001e6608",ServerName,"REG_SZ"

	            WSHShell.RegWrite path & "001e6602",ServerName,"REG_SZ"

		   End If


		If err then

	    	      msgbox "Error Encountered Changing Exchange Server Name" & vbCrLf & "Please contact the help desk."

		else

		      Wscript.Quit

		End if

	        Wscript.Quit

 

         End If

     Next

Next

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top