Looking for utility to clean out all user's temp files

tuser

n00b
Joined
Feb 17, 2010
Messages
7
I'm looking for a program that deletes the internet temp files from all users on a computer. CCleaner only deletes the currently logged in computer, if anyone knows I'd appreciate the help. Thanks!
 
Here's some quick and dirty VBS an ex-coworker and I wrote...key words are quick and dirty....I wont claim that it nukes everything, but it gets close...ymmv
Code:
On Error Resume Next

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objNetwork = CreateObject("Wscript.Network")
Set objShell = CreateObject("Shell.Application")
'Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshSysEnv = WshShell.Environment("PROCESS")

MsgBox "For best results this tool should be executed while logged in as an Administrator",0,"Temp/Cookie Cleaner"

intAnswer = Msgbox("Are you sure you want to delete all temp/cookie files?",vbYesNo,"Temp/Cookie Cleaner")

If intAnswer = vbNo Then
    WScript.Quit [exitcode]
End If

objFSO.DeleteFolder "c:\temp\*"
objFSO.DeleteFile "c:\temp\*.*"
'objShell.Open "c:\temp"

objFSO.DeleteFolder "c:\windows\Prefetch\*"
objFSO.DeleteFile "c:\windows\Prefetch\*.*"
'objShell.Open "c:\windows\Prefetch"

objFSO.DeleteFolder "c:\windows\temp\*"
objFSO.DeleteFile "c:\windows\temp\*.*"
'objShell.Open "c:\windows\temp"

strFolder = "c:\documents and settings\"

Set objFolder = objFSO.GetFolder(strFolder)

Set colFolders = objFolder.SubFolders

  For Each objSubFolder In colFolders
    If objSubFolder.Path = "C:\Documents and Settings\Default User" Or objSubFolder.Path = "C:\Documents and Settings\All Users" Or objSubFolder.Path = "C:\Documents and Settings\LocalService" Or objSubFolder.Path = "C:\Documents and Settings\NetworkService" Then
    
    Else
        'WScript.Echo objSubFolder.Path
        strPath = objSubFolder.Path
        objFSO.DeleteFile strPath & "\Cookies\*.*", true
        objFSO.DeleteFolder strPath & "\Cookies\*", true
        objFSO.DeleteFile strPath & "\Local Settings\Temp\*.*", true
        objFSO.DeleteFolder strPath & "\Local Settings\Temp\*", true
        objFSO.DeleteFile strPath & "\Local Settings\Temporary Internet Files\*.*", true
        objFSO.DeleteFolder strPath & "\Local Settings\Temporary Internet Files\*", true
    End If
  Next

wscript.sleep 10000

'objExplorer.Visible = 0

BtnPress = WshShell.Popup("Temp/Cookie Cleaner completed          ",7, "Temp/Cookie Cleaner", 0 + 64)

' clean up
Set objShell= nothing
Set objNetwork = nothing
Set objFSO = nothing
Set objExplorer = nothing
 
Ccleaner has a silent switch.

I've used this on terminal servers a few times. Just place it in the All Users startup and it will run when the user logs in.

Don't keep it there all the time though.

Riley
 
Here is the clean.cmd file I run weekly on our shared machines.

@echo off

echo DELTEMP.CMD is designed to delete temporary files on a multiuser system,
echo Such as Terminal Server.
echo
echo - WARNING!!!
echo - This batch file DELETES FILES!!!
echo
echo - Please make sure that you know exactly what is going to be done.
echo - It is recommended to test in a lab first.
echo
echo - The idea here is to clean up files from temp folders of all users on a machine.
echo - This can be most useful in a multi user system like Terminal Server.
echo
pause

IF "%OS%"=="" GOTO WIN9X
@REM - FIND "DOCUMENTS AND SETTINGS" FOLDER:
SET LOGPATH="C:\Temp"
%SYSTEMDRIVE%
CD %USERPROFILE%\..
FOR /D %%F IN (*.*) DO DEL /F/S/Q "%%F\LOCAL SETTINGS\TEMP\*.*"
FOR /D %%F IN (*.*) DO DEL /F/S/Q "%%F\LOCAL SETTINGS\TEMPORARY INTERNET FILES\*.*"
DEL /F/S/Q %WINDIR%\TEMP\*.*
DEL /F/S/Q %WINDIR%\Prefetch\*.*
DEL /F/S/Q %WINDIR%\Web\Wallpaper\*.*
DEL /F/S/Q %WINDIR%\*.TMP
DEL /F/S/Q %WINDIR%\*.Log
rmdir /S /Q "%WINDIR%\Temp"
mkdir "%WINDIR%\Temp"

:GOTO END

:WIN9X
REM - WIN9X systems are currently not supported.

:END
 
Back
Top