Celeri Posted August 7, 2005 Posted August 7, 2005 If anyone's interested, I recently set out to write a small AutoIT script to clean up computers with many users and a million useless temporary files. It works great (on my computer anyways) and it's godsent in BartPE (bootable XP CD) since it's a pain to manually flush every folder. It isn't pretty but if anyone wants to try it out feel free Oh yeah it isn't "optimized" and there's a lot of useless redundant code. I might get around to tightening it eventually. Also it hasn't been tested on too many computers so you should take care in running the program since it does delete stuff ... so please don't trust it too blindly Here ya go: expandcollapse popup; MiniCleaner 1.04 ; A simple program to delete ALL temporary data on a single computer, recursively ; going through all possible folders and drives ; Still rather experimental so be careful!!! ; A good candidate for BartPE;) ; In english to be able to share with ... english programmers ; ; Louis Horvath, 6 aout 2005 ; ==== SYSTEM VARIABLES ====================================================== #NoTrayIcon; No annoying tray icon #include <GuiConstants.au3>; Needed to make GUIs #include <Array.au3>; Needed to work with arrays ; ==== PROGRAM VARIABLES ===================================================== $WIN = "\Windows"; Most common folder for windows $WINNT = "\WinNT"; Windows NT $DAS = "\Documents and Settings"; Base of all user data $LS_Temp = "\Local Settings\Temp"; All those pesky temp files $LS_TIF = "\Local Settings\Temporary Internet Files\Content.IE5"; All that crappy IE stuff $Temp = "\Temp"; Simple temporary folder (usually within Windows) $Systemprofile = "\system32\config\systemprofile"; Nicely hidden junk ... $All = "\*.*"; All files within $S = "\"; Backslash Dim $Drives[26]; Array containing all drive letters and data ; ==== MAIN PROGRAM ========================================================== ; Verify if user is administrator (!) If Not IsAdmin() Then Exit; Rather self-explanatory ; Make sure program is started only once Verif_PROG() ; Get list of drives on system $Drive_AMOUNT = Find_DRIVES() ; ==== SETUP PROMPT ========================================================== $iMsgBoxAnswer = MsgBox(547, "MiniCleaner v.1.04", "MiniCleaner will erase ALL temporary files" & @CRLF & "for all users on this computer." & @CRLF & @CRLF & "Would you like a verbose output?" & @CRLF & "(usually for debug purposes)") Select Case $iMsgBoxAnswer = 6;Yes $Verbose = 1 Case $iMsgBoxAnswer = 7;No $Verbose = 0 Case $iMsgBoxAnswer = 2;Cancel Exit EndSelect ; ==== MAIN LOOP ============================================================= ; Go through with all drives on system For $i = 1 To $Drive_AMOUNT ; Clear out Temp in main drive folder If FileExists($Drives[$i] & $Temp) Then If $Verbose Then MsgBox(1, "Clear out Temp in main drive folder", "Erasing " & $Drives[$i] & $Temp) Zap_FOLDER($Drives[$i] & $Temp) EndIf ; Clear out Temp within Windows folder If FileExists($Drives[$i] & $WIN & $Temp) Then; Temp in main drive folder If $Verbose Then MsgBox(1, "Clear out Temp within Windows folder", "Erasing " & $Drives[$i] & $WIN & $Temp) Zap_FOLDER($Drives[$i] & $WIN & $Temp) EndIf ; Clear out (hidden) temp within SystemcProfile folder If FileExists($Drives[$i] & $WIN & $Systemprofile & $LS_Temp) Then; Temp in main drive folder If $Verbose Then MsgBox(1, "Clear out (hidden) temp within SystemcProfile folder", "Erasing " & $Drives[$i] & $WIN & $Systemprofile & $LS_Temp) Zap_FOLDER($Drives[$i] & $WIN & $Systemprofile & $LS_Temp) EndIf ; Clear out (hidden) IE files within SystemcProfile folder If FileExists($Drives[$i] & $WIN & $Systemprofile & $LS_TIF) Then; Temp in main drive folder If $Verbose Then MsgBox(1, "Clear out (hidden) IE files within SystemcProfile folder", "Erasing " & $Drives[$i] & $WIN & $Systemprofile & $LS_TIF) Zap_FOLDER($Drives[$i] & $WIN & $Systemprofile & $LS_TIF) EndIf ; Clear out Temp within WinNT folder If FileExists($Drives[$i] & $WINNT & $Temp) Then; Temp in main drive folder If $Verbose Then MsgBox(1, "Clear out Temp within WinNT folder", "Erasing " & $Drives[$i] & $WINNT & $Temp) Zap_FOLDER($Drives[$i] & $WINNT & $Temp) EndIf ; Clear out (hidden) temp within SystemcProfile folder If FileExists($Drives[$i] & $WINNT & $Systemprofile & $LS_Temp) Then; Temp in main drive folder If $Verbose Then MsgBox(1, "Clear out (hidden) temp within SystemcProfile folder", "Erasing " & $Drives[$i] & $WINNT & $Systemprofile & $LS_Temp) Zap_FOLDER($Drives[$i] & $WINNT & $Systemprofile & $LS_Temp) EndIf ; Clear out (hidden) IE files within SystemcProfile folder If FileExists($Drives[$i] & $WINNT & $Systemprofile & $LS_TIF) Then; Temp in main drive folder If $Verbose Then MsgBox(1, "Clear out (hidden) IE files within SystemcProfile folder", "Erasing " & $Drives[$i] & $WINNT & $Systemprofile & $LS_TIF) Zap_FOLDER($Drives[$i] & $WINNT & $Systemprofile & $LS_TIF) EndIf ; Empty the recycle bin just in case ... If $Verbose Then MsgBox(1, "Empty Recycle Bin", "Emptying RecycleBin on drive " & $Drives[$i]) FileRecycleEmpty($Drives[$i]) ; Search and destroy within Documents and Settings If FileExists($Drives[$i] & $DAS) Then; Documents and Settings on this drive If $Verbose Then MsgBox(1, "DAS", "Documents and Settings found on drive " & $Drives[$i]) $FFF_DAS = FileFindFirstFile($Drives[$i] & $DAS & $All); Start off search If $FFF_DAS <> - 1 Then; Follow through if more than 0 elements found While 1 $Next_DAS = FileFindNextFile($FFF_DAS); Get the folder's name If @error Then ExitLoop; Whoops, finished If $Next_DAS <> "." And $Next_DAS <> ".." Then If FileExists($Drives[$i] & $DAS & $S & $Next_DAS & $LS_Temp) Then; If there are any temp files If $Verbose Then MsgBox(1, "DAS", "Cleaning " & $Drives[$i] & $DAS & $S & $Next_DAS & $LS_Temp) Zap_FOLDER($Drives[$i] & $DAS & $S & $Next_DAS & $LS_Temp) EndIf If FileExists($Drives[$i] & $DAS & $S & $Next_DAS & $LS_TIF) Then; If there is any IE files If $Verbose Then MsgBox(1, "DAS", "Cleaning " & $Drives[$i] & $DAS & $S & $Next_DAS & $LS_TIF) Zap_FOLDER($Drives[$i] & $DAS & $S & $Next_DAS & $LS_TIF) EndIf EndIf WEnd FileClose($FFF_DAS); Tidyup and close search EndIf EndIf Next ; Exit MsgBox(1, "Operation complete", "Cleanup complete!") Exit ; ==== FUNCTIONS ============================================================= Func Zap_FOLDER($Var1); ...................................................... ; $Var1 = Folder who's content will be flushed FileSetAttrib($Var1 & $All, "-RASHNOT", 1); Remove all attributes FileDelete($Var1 & $All); Start by erasing all files ; Let's make this simple - whatever is left is probably a folder $Var2 = FileFindFirstFile($Var1 & $All); Start off search If $Var2 = -1 Then; It's an empty folder ... FileClose($Var2); Tidyup and close search Return; No more files EndIf ; Ok then delete all folders ... While 1 $Var3 = FileFindNextFile($Var2); Find first folder If @error Then ExitLoop; We passed last folder If $Var3 <> "." And $Var3 <> ".." Then DirRemove($Var1 & "\" & $Var3, 1); And now erase that folder EndIf WEnd; Until such a time as all folders are deleted FileClose($Var2); Tidyup and close search EndFunc ;==>Zap_FOLDER Func Verif_PROG(); .......................................................... $g_szVersion = "MiniCleaner"; Name this program If WinExists($g_szVersion) Then Exit; Already there! AutoItWinSetTitle($g_szVersion) EndFunc ;==>Verif_PROG Func Find_DRIVES(); ......................................................... $Drives = DriveGetDrive( "FIXED"); Get all hard drives If Not @error Then Return $Drives[0]; Returns the # of drives found Else MsgBox(16, "Error", "No harddrives available!"); Whoops? Exit EndIf EndFunc ;==>Find_DRIVES I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)
Celeri Posted August 8, 2005 Author Posted August 8, 2005 Well it's really sad no one found this useful ... I've discovered that the FileDelete function has an annoying limitation. It will quit as soon as it has any problem (locked file, readonly, etc. etc. etc.) and I didn't find any way of forcing it to delete. It might cause the program to miss a large number of files, specially if the problem file is found early by FileDelete. As seen in the program, I've taken the liberty to remove all attributes before deleting, which does help. I'll implement a "garbage collection" routine that checks on the FileDelete function and if files are left will try to delete files individually. I think this will preserve speed as much as possible - I think deleting files individually must be much slower than deleting them with FileDelete("*.*") If anyone replies I'd be happy to post the result of my work. Obi Wan Celeri I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)
ACalcutt Posted August 9, 2005 Posted August 9, 2005 I am going to give this a try because i remove spyware and viruses alot for my job... i was just wondering though....have you ever tried "EzPCFix" for bartpe?.... removes temp files/history/cookies/restore points...you can also load the registry hives and have more options to do (i dont use them so i cant go into detail)...but ezpcfix is a great toolhttp://ezpcfix.net/ Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature
HeX Posted August 10, 2005 Posted August 10, 2005 FileSetAttrib($Var1 & $All, "-RASHNOT", 1); Remove all attributes Oh come on. Why doesn't it say "-NOTRASH"?! On quick glance, I'm wondering why not use @TempDir and stuff? Good code though, especially for those who don't STORE stuff in C:\temp as I've seen happen
rakudave Posted August 10, 2005 Posted August 10, 2005 @ACalcutt: quite nice, this EzPCFix, but i miss the "do all" function. Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table
ACalcutt Posted August 10, 2005 Posted August 10, 2005 @ACalcutt:quite nice, this EzPCFix, but i miss the "do all" function.<{POST_SNAPBACK}>you could right an autoit program for that ...lol Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature
Celeri Posted August 10, 2005 Author Posted August 10, 2005 you could right an autoit program for that ...lol<{POST_SNAPBACK}>I might ... BTW did you try http://www.ccleaner.com/? It's as complete as you are going to get for a clean-all solution (athough it only does the current user, which is why I came out with my program). It's probably also not very good from within BartPE (bootable Windows XP CD) while my program is best in that regardBTW, I have a "final" version if anyone is interested. I say final but we all know there's always something to add somehwere As far as EzPCFix is concerned I'll check it out (there is a lot of great software out there!!!) but I'm willing to bet my version is faster ehehehehe (well maybe not but it's nice to brag anyways eheheh). Obi Wan CeleriP.S.: I might add a function to auto-clean at startup. Do you think it would be a good idea? I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)
Celeri Posted August 10, 2005 Author Posted August 10, 2005 Oh come on. Why doesn't it say "-NOTRASH"?! On quick glance, I'm wondering why not use @TempDir and stuff?Good code though, especially for those who don't STORE stuff in C:\temp as I've seen happen <{POST_SNAPBACK}>"-NOTRASH" .... ahhahahahahahah I'll try and see if it works and if it does I'll keep it and suggest it as the default value to the AutoIT team ahahahaha.... good one ahahahaah"why not use @TempDir". The reason is quite simple. My program doesn't care where a user puts his temp files really, it cleans up all places where you usually find temp files (hopefully no personnal files ehehehe) and cleans them up arbitrarily. It is, after all, a program to clean up all users, so if the user running the programs uses another drive / folder than other users, there might be temp files left lying around ... mind you I could go bonkers and start searching all over the place for "\Temp" or "\Tmp" but it would slow down the process significantly.Sorry for the long-winded response I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)
Celeri Posted August 10, 2005 Author Posted August 10, 2005 (edited) Ok what the heck, here's my latest (and perhaps final?) source code ... Made BTW with plain AutoIT 3.11 (could never get those bloody betas to install properly with SCITE ... must be blind or dumb ehehehe What's new compared to the previous version? - Checks for /S on command line and works silently (great to run at startup) - Shows a window (in verbose mode) where all folders and files deleted are shown (a one-liner to increase speed) - Credits and stuff - Keep on deleting files even when FileDelete hits a locked file and quits (forgot that one on my initial post - curious since I'm pretty happy about that solution) I hope I didn't forget anything, I've produced two versions, one in french and one in english (included). Both tested - they should work as advertised If you find anything (good or bad) please tell me I'll gladly fix it BTW next version will mention this program has been done in AUTOIT3 ... Edited August 10, 2005 by Celeri I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)
ACalcutt Posted August 11, 2005 Posted August 11, 2005 i could not get that script to work...or does it not show any alerts.... Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature
Celeri Posted August 11, 2005 Author Posted August 11, 2005 i could not get that script to work...or does it not show any alerts....<{POST_SNAPBACK}>That's weird ...Please note there's a way to run the script silently so maybe... it's stuck in silent mode? i.e.: MiniCleaner.exe /sLet me check and I'll come back to you on that (this really sucks since I put a lot of work into debugging the damn thing before posting it here!) I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)
Valuater Posted August 12, 2005 Posted August 12, 2005 I like your code... it shows me areas that i missed in mineI was not that impressed with EzPCFix... this is the temp screenhttp://ezpcfix.net/img/temp.gifHere is minehttp://xpcleanmenu.hostrocket.com/image/Auto-screen.jpgYou went for cleaning all users... I went for (safety) restore point, adware, spyware, cleaning temps, cleaning registry, and then defrag... later it had a disappearing top menu bar... and now it has top menu bar "skins"...http://www.autoitscript.com/forum/index.ph...9&t=11334&st=0#Well it was fun... yours has great ideas too!8) PS the actual web site is below
ACalcutt Posted August 12, 2005 Posted August 12, 2005 (edited) still no luck .... I still havent been able to get it to work...i am pretty sure i am not running it in silent mode...just trying to run the au3 or comiled au3...no switch after it Edited August 12, 2005 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature
Celeri Posted August 13, 2005 Author Posted August 13, 2005 (edited) still no luck ....I still havent been able to get it to work...i am pretty sure i am not running it in silent mode...just trying to run the au3 or comiled au3...no switch after it<{POST_SNAPBACK}>This is really curious ...Would you mind me sending you a compiled binary to see if the problem persists? If the compiled version works then we know the problem happens either during compilation or while running. The first one would indicate a version problem and the second one could be caused by an anti-virus program.Mind you this could also be completely my fault - it's happened before BTW if you use SCITE, can you run the script properly? P.S.: Tried it at a few places and no problems... could it be localisation or something? Edited August 13, 2005 by Celeri I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)
Celeri Posted August 14, 2005 Author Posted August 14, 2005 I like your code... it shows me areas that i missed in mineI was not that impressed with EzPCFix... this is the temp screenhttp://ezpcfix.net/img/temp.gifHere is minehttp://xpcleanmenu.hostrocket.com/image/Auto-screen.jpgYou went for cleaning all users... I went for (safety) restore point, adware, spyware, cleaning temps, cleaning registry, and then defrag... later it had a disappearing top menu bar... and now it has top menu bar "skins"...http://www.autoitscript.com/forum/index.ph...9&t=11334&st=0#Well it was fun... yours has great ideas too!8) PSÂ the actual web site is below<{POST_SNAPBACK}>Your program is very interesting but yes, it really is different It looks more like an all-in-one optimising tool.My program only tackles one aspect - cleaning up the bulk of the crap that accumulates on a computer.Strangely BTW, I could not compile your code, (the one refered from the link) it kept on throwing errors at me Weird since the code looks OK. But your program is rather big so I haven't had a chance to really read alot of it. If there's anything I will tackle in the future is making a multi-language version that automatically switches, depending on the OS's language. Not an easy feat since it often leads to ugly interfaces!!! I've done it before and it's a real pain but the end result is very satisfying Translation would be simple since the languages would be handled by an .INI file. And the program auto-creates the .INI file if it doesn't exist ... I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)
Valuater Posted August 15, 2005 Posted August 15, 2005 Your program is very interesting but yes, it really is different It looks more like an all-in-one optimising tool.My program only tackles one aspect - cleaning up the bulk of the crap that accumulates on a computer.Strangely BTW, I could not compile your code, (the one refered from the link) it kept on throwing errors at me Weird since the code looks OK. But your program is rather big so I haven't had a chance to really read alot of it. If there's anything I will tackle in the future is making a multi-language version that automatically switches, depending on the OS's language. Not an easy feat since it often leads to ugly interfaces!!! I've done it before and it's a real pain but the end result is very satisfying Translation would be simple since the languages would be handled by an .INI file. And the program auto-creates the .INI file if it doesn't exist ...<{POST_SNAPBACK}>I'm really not sure why it can't be compilled.. but as for the languages, maybe you should take a look at thishttp://www.autoitscript.com/forum/index.ph...powertranslate#hope it helps8)
benzipperer Posted August 17, 2005 Posted August 17, 2005 I like your code, it is perfect for Bart PE. I hope to use it as a quick cleaner for working on various machines.
Celeri Posted August 21, 2005 Author Posted August 21, 2005 I'm really not sure why it can't be compilled.. but as for the languages, maybe you should take a look at thishttp://www.autoitscript.com/forum/index.ph...powertranslate#hope it helps8)<{POST_SNAPBACK}>That's amusing PowerTranslate uses a similar technique to mine ... except I've used 3D arrays ...As per example ... Dim $Message[100][2] $Lang = 1; 1 = English, 51 = French, etc. etc. $Message = Load_Messages("Messages.lng") $Title=0 $Content=1 MsgBox(1,$Message[$Lang][$Title],$Message[$Lang][$Content]) MsgBox(1,$Message[$Lang+1][$Title],$Message[$Lang+1][$Content]) etc. etc.But the whole process is really unbearable. It simply doubles all the work and I really, really hate it The beautiful part however is that you can change languages on the fly. Just need to change the offset and redraw the GUI and there I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)
Mosquitos Posted August 23, 2005 Posted August 23, 2005 Maybe you can add how many files the script deleted and how many kb... and delete also the bak,old,tmp etc files like valuater in his xpclean. Sapiente vince, rex, noli vincere ferro!
Matrix112 Posted August 24, 2005 Posted August 24, 2005 I dont think i need this, I use my cleaner.bat I think this is more simple. @echo off cls title Cleaner fuer Internet PCs rem ------------------------------------------------------------------------------ rem Name: Cleaner.bat rem Autor: Christoph Krogmann rem Co Autor: Torsten Hill rem Datum: 9. November 2004 rem ------------------------------------------------------------------------------ color 1f echo %date% echo %Time% Internetspuren werden beseitigt... echo. echo. cd\ c: del index.dat /s /f /q del "%TEMP%\*.*" /s /f /q /a:h del "%TMP%\*.*" /s /f /q /a:h del "%UserProfile%\Lokale Einstellungen\Temporary Internet Files\*.*" /s /f /q /a:h del "%UserProfile%\Lokale Einstellungen\Verlauf\*.*" /s /f /q /a:h del "%UserProfile%\Cookies\*.*" /s /f /q /a:h del "%SystemRoot%\Temp\*.*" /s /f /q /a:h echo. echo %Time% echo Alle Spuren bis auf die angezeigten probleme wurden beseitigt. Um die problem Dateien zu entfernen, starten sie den Computer im abgesicherten Modus und fuehren sie dieses Programm erneut aus. Es wird empfohlen, dieses Programm im abgesicherten Modus auszufuehren, da nur dann alle Dateien beseitigt werden koennen. echo. pause Sorry for german text, I think you know what it is doing.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now