Clear temp files Quick and Dirty
March 13, 2008 8:48 PM   Subscribe

I'd like to create a batch file to clear out my cookies and Temporary Internet Files folder.

I'd like a script that I can double click on whenever I feel the need to clear cookies or Temp Internet Files. I know how to clear them manually on IE. I just want an easier way. This is only for IE at work (although I'm a religious Opera user). I don't know any visual basic. I assume a batch file command might work.
posted by sonicbloom to Computers & Internet (8 answers total) 2 users marked this as a favorite
 
The following lines in a batch file should work:

del "C:\Documents and Settings\%USERNAME%\Cookies\*.*"
del "C:\Documents and Settings\%USERNAME%\Local Settings\Temporary Internet Files\*.*"
posted by pompomtom at 9:19 PM on March 13, 2008


If you're looking for a similar concept with a few more features that will also clean out temp files from other apps, try CCleaner.
posted by Inspector.Gadget at 9:25 PM on March 13, 2008


pompomtom's solution will work if you just want to get rid of the cookies and files. Note, however, that the index files that contain the names of all the cookies and files will still be there. The index files (index.dat) can't be deleted unless you are logged in as an administrator and are deleting another user's files. Even CCleaner can't delete your index files until you reboot.
posted by ssg at 9:41 PM on March 13, 2008


That is why you want to use Firefox or the like for when you want easy cleaning.
posted by caddis at 4:17 AM on March 14, 2008


That is why you want to use Firefox or the like for when you want easy cleaning.
In fact you can set firefox to clear out all private information whenever you quit. No scripts required.
posted by shothotbot at 4:42 AM on March 14, 2008


Seconding CCleaner.
posted by zippy at 12:58 PM on March 14, 2008


Dowload MRU Blaster from JavaCool software at http://www.javacoolsoftware.com/mrublaster.html
This is the most excellent cookie cleaner and IE temp file remover! It allows you to selectively keep some Cookies if you wish (e.g. I need an online game history cookie to be saved). It will also clear out any persistent local history files in Win (files most recently acccessed etc.) -- alll stuff that a software intrusion could access to get information about you. I really recommend this program -- and it is free ... :-)
posted by sgmax at 6:35 PM on March 14, 2008


Create the following VBS file below (yes, I know, Visual Basic is da debil, but this is the only way you can script running under alternate credentials under Windows). Save the file someplace easy to type. Your root directory, for example.

Create a batch file. The batch file simply calls the VBScript, passing along any hard-coded user accounts / passwords you need to run the commands as Administrator. NOTE: Don't do this on a production box unless you like getting pwnd. I take no responsibility yadda yadda yadda...

The batch file should contain the actual delete statements. The paths given above are right on track. Add @ CALL [whatever DEL statements you like] to the statements. Then add a @ CALL (name of your batch file) to some place in your autoexec.bat so it gets called every time the system starts.
'Start of Script
'VBRUNAS.VBS
'v1.2 March 2001
'Jeffery Hicks
'jhicks@quilogy.com http://www.quilogy.com
'USAGE: cscript|wscript VBRUNAS.VBS Username Password Command
'DESC: A RUNAS replacement to take password at a command prompt.
'NOTES: This is meant to be used for local access. If you want to run a command
'across the network as another user, you must add the /NETONLY switch to the RUNAS
'command.

' *********************************************************************************
' * THIS PROGRAM IS OFFERED AS IS AND MAY BE FREELY MODIFIED OR ALTERED AS *
' * NECESSARY TO MEET YOUR NEEDS. THE AUTHOR MAKES NO GUARANTEES OR WARRANTIES, *
' * EXPRESS, IMPLIED OR OF ANY OTHER KIND TO THIS CODE OR ANY USER MODIFICATIONS. *
' * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED IN A SECURED LAB *
' * ENVIRONMENT. USE AT YOUR OWN RISK. *
' *********************************************************************************

On Error Resume Next
dim WshShell,oArgs,FSO

set oArgs=wscript.Arguments

if InStr(oArgs(0),"?")<>0 then
wscript.echo VBCRLF & "? HELP ?" & VBCRLF
Usage
end if

if oArgs.Count <3>
wscript.echo VBCRLF & "! Usage Error !" & VBCRLF
Usage
end if

sUser=oArgs(0)
sPass=oArgs(1)&VBCRLF
sCmd=oArgs(2)

set WshShell = CreateObject("WScript.Shell")
set WshEnv = WshShell.Environment("Process")
WinPath = WshEnv("SystemRoot")&"\System32\runas.exe"
set FSO = CreateObject("Scripting.FileSystemObject")

if FSO.FileExists(winpath) then
'wscript.echo winpath & " " & "verified"
else
wscript.echo "!! ERROR !!" & VBCRLF & "Can't find or verify " & winpath &"." & VBCRLF & "You must be running Windows 2000 for this script to work."
set WshShell=Nothing
set WshEnv=Nothing
set oArgs=Nothing
set FSO=Nothing
wscript.quit
end if

rc=WshShell.Run("runas /user:" & sUser & " " & CHR(34) & sCmd & CHR(34), 2, FALSE)
Wscript.Sleep 30 'need to give time for window to open.
WshShell.AppActivate(WinPath) 'make sure we grab the right window to send password to
WshShell.SendKeys sPass 'send the password to the waiting window.

set WshShell=Nothing
set oArgs=Nothing
set WshEnv=Nothing
set FSO=Nothing

wscript.quit

'************************
'* Usage Subroutine *
'************************
Sub Usage()
On Error Resume Next
msg="Usage: cscript|wscript vbrunas.vbs Username Password Command" & VBCRLF & VBCRLF & "You should use the full path where necessary and put long file names or commands" & VBCRLF & "with parameters in quotes" & VBCRLF & VBCRLF &"For example:" & VBCRLF &" cscript vbrunas.vbs quilogy\jhicks luckydog e:\scripts\admin.vbs" & VBCRLF & VBCRLF &" cscript vbrunas.vbs quilogy\jhicks luckydog " & CHR(34) &"e:\program files\scripts\admin.vbs 1stParameter 2ndParameter" & CHR(34)& VBCRLF & VBCRLF & VBCLRF & "cscript vbrunas.vbs /?|-? will display this message."

wscript.echo msg

wscript.quit

end sub
'End of Script
 

posted by Civil_Disobedient at 9:12 PM on March 14, 2008


« Older Cool accessories for a dude   |   Where to stargaze around Austin? Newer »
This thread is closed to new comments.