Automaton Posted March 12, 2008 Share Posted March 12, 2008 Guys, I wrote this script, and it worked fine, but as I've run this script on my laptop a few times, CCleaner says there is nothing to clean, so my script falls over. Could you guys take a look and tell me how to improve the script (aside from hard coding of file paths etc) If you run the script, it'll delete temp files and clean you registry of hanging entries, etc, so you have been warned. CODE#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #cs 2. CCleaner #ce ;Run("Exe/StartUpLite.exe") ;WinWaitActivE("StartUpLite") ;Run("Exe/MSConfigCleanup.exe") ;Run("C:\Program Files\MSConfig CleanUp\MSConfigCleanUp.exe") ;WinWaitActive("MSConfig") Func installCCleaner () Run("Installers/CCleaner.exe") WinWaitActive("Installer Language") Send("{ENTER}") WinWaitActive("CCleaner", "Click Next to continue") Send("{ENTER}") WinWaitActive("CCleaner", "License Agreement") Send("{ENTER}") WinWaitActive("CCleaner", "Choose Install Location") Send("{ENTER}") WinWaitActive("CCleaner", "Install Options") Send("{ENTER}") WinWaitActive("CCleaner", "has been installed") Send("{ENTER}") EndFunc Func runCCleaner() ; if already installed then run if FileExists("C:\Program Files\CCleaner\ccleaner.exe") Then ; Execute Disk Cleaner Run("C:\Program Files\CCleaner\ccleaner.exe") WinWaitActive("Piriform CCleaner", "updates") Send("+{TAB}") Send("{ENTER}") ; Tab Cleaner WinWaitActive("", "This process will permanently delete files") Send("{ENTER}") WinWaitActive("Piriform CCleaner", "CLEANING COMPLETE") ; Tab Registry Send("!g") WinWaitActive("Piriform CCleaner", "can for Issues") Send("!s") ; Backup registry? WinWaitActive("CCleaner", "Do you want to backup changes", 5) Send("!y") Send("!s") WinWaitActive("","Fix All Selected Issues", 5) Send("{TAB 3}") Send("{SPACE}") WinWaitActive("CCleaner", "Are you sure", 5) Send("{SPACE}") WinWaitActive("", "Issue Fixed", 5) Send("{TAB}") Send("{SPACE}") ; Exit CCleaner ;WinWaitActive("Piriform CCleaner", "CLEANING COMPLETE") ;Send("!{F4}") EndIf EndFunc Func uninstallCCleaner() if FileExists("C:\Program Files\CCleaner\uninst.exe") Then Run("C:\Program Files\CCleaner\uninst.exe") WinWaitActive("CCleaner", "Uninstall Wizard") Send("{SPACE}") WinWaitActive("CCleaner", "will be uninstalled") Send("{SPACE}") WinWaitActive("CCleaner", "to close this wizard") Send("{SPACE}") EndIf EndFunc ;installCCleaner() runCCleaner() ;uninstallCCleaner() Link to comment Share on other sites More sharing options...
weaponx Posted March 12, 2008 Share Posted March 12, 2008 Silent install/run is superior in terms of reliability.#473323 Link to comment Share on other sites More sharing options...
Automaton Posted March 13, 2008 Author Share Posted March 13, 2008 Silent install/run is superior in terms of reliability.#473323Thanks for the heads up.At least I learned from doing.I tried using the /auto switch and found that it doesn't complain (and doesn't do the job) if you have a IE or Firefox window open. If you try to run CCleaner normally, it will complain if either IE or Firefox is open. So I would suggest not running it in auto mode unless you remember to kill your browsers, otherwise it won't clean properly. Link to comment Share on other sites More sharing options...
weaponx Posted March 13, 2008 Share Posted March 13, 2008 Thanks for the heads up.At least I learned from doing.I tried using the /auto switch and found that it doesn't complain (and doesn't do the job) if you have a IE or Firefox window open. If you try to run CCleaner normally, it will complain if either IE or Firefox is open. So I would suggest not running it in auto mode unless you remember to kill your browsers, otherwise it won't clean properly.Well there is a more elegant solution.$process1 = "iexplore.exe"$process2 = "firefox.exe"MsgBox(0,"Warning!","All instances of Internet Explorer / Firefox will be closed in 5 seconds", 5)While ProcessExists($process1)ProcessClose($process1)WEndWhile ProcessExists($process2) ProcessClose($process2) WEnd$result = RunWait("ccleaner /auto") Link to comment Share on other sites More sharing options...
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