5 sätt att städa upp datorn med ett automatiskt skript [Windows]
Datorunderhåll är inte precis något som de flesta människor kommer ihåg att göra. För den allmänna användaren som inte är precis tekniskt kunnig, när en dator inte fungerar, ber de antingen om hjälp eller helt enkelt köpa en ny dator.
Om du har familjemedlemmar eller vänner som alltid ringer dig till hjälp med en långsam dator kommer jag att erbjuda dig en lösning som du kan använda för att stoppa dessa telefonsamtal just nu. Denna lösning innehåller sex verktyg i ett Windows-skript. Det manuset kommer att utföra allt PC-rengöringsarbete som du skulle göra om du sitter precis framför datorn själv.
Vad detta skript kommer att utföra
Detta Windows-skript kommer att köra de nödvändiga verktygen i kommandoradsläget. Många av dessa verktyg som du har använt i åratal, kanske du inte ens insett det där är ett kommandoradsläge tillgängligt.
Rensa registret och Temp-mappar
Det första steget är förmodligen det viktigaste. Vi ska starta CCleaner i kommandoradsläge för att städa upp tempfiler och registret.
En fångst. För att göra det här skriptet fungera utan ständiga meddelanden om de appar som gör datorändringar måste du inaktivera funktionen Användarkontokontroll i Windows 7.
Nu är du redo att rulla. Skapa en fil som heter CleanComputer.wsf och starta av med följande skript.
Option Explicit
On Error Resume Next
Dim WshShell
Dim retVal
set WshShell=CreateObject("WScript.Shell")
WshShell.run "CCleaner.exe /AUTO"
Danny covered CCleaner Optimize Your System To Run At Its Best With CCleaner Optimize Your System To Run At Its Best With CCleaner Over the last two years, CCleaner has changed quite a bit in terms of version numbers… up now to version 3.10 at the time of this writing. While visually the program actually hasn't changed much (it's… Read More recently, so you can see just what it is capable of and how much it can optimize your system. When you launch it in the script as shown above with the /AUTO flag, it'll run invisible and it'll use the settings you used when you last ran the application. You'll see CCleaner.exe running in the Task Manager.
If you configure CCleaner beforehand, in auto mode it'll automatically clean up temporary files, log files and your registry as well.
Clean Up Spyware
Next up is to take care of any spyware that might be running on the PC. My favorite tool for that is Spybot, and luckily Spybot also offers a command line feature. The one problem here is that the path to Spybot is full of spaces, which is hard to handle in a Windows Script shell command.
So, create a .bat file with the following:
C:\Program Files (x86)\Spybot - Search & Destroy\SpybotSD.exe" /taskbarhide /autocheck /autofix /autoclose
Exit
Save it as SpyBot.bat in the same directory as your Windows script. Then in the next line of your WSF file, add the following:
WshShell.run "spybot.bat"
Your Windows Script will launch your batch job that will launch Spybot in command-line mode. You will know it's running when the Exe appears in the task manager.
Those four parameters after the spybotsd.exe file will run Spybot in silent mode, automatically remove any spyware found, and then automatically close.
Remove Malicious Software
In addition to anything Spybot catches, I also like to run the Microsoft Malicious Software removal tool. Download the executable from the “Microsoft Download Center” section, save it in your script directory as “malremove.exe” and then add the following line to your growing Windows Script.
WshShell.run "malremove.exe /Q /F:Y"
The /Q command tells the malware removal tool to run in quiet mode (no interface) and /F:Y tells it to forcibly remove any malware that it finds without any intervention required. The first time you run it during your initial testing, you'll have to select the option for no warning the next time it runs.
Here it is running in the background.
So, we've covered most of what you'd probably do if you were there in person - run CCleaner to get rid of temporary Internet files and other temp files, remove spyware and malware, so what's left?
Automate Disk Cleanup
Another common tool that can help computer performance is the Windows Disk Cleanup tool. First you have to set it up. Go to Start -> Run and type: “cleanmgr /sageset:1“. The following window will appear.
Set up the items that you'd like your command line to automatically clean, and then click OK. This tells it that whenever you choose /sageset:1, to utilize the settings you've just created. Now, in your Windows Script, add the following line.
WshShell.run "Cleanmgr /sagerun:1"
This will run the Windows disk cleanup silently, using the settings you've just created. You can also install the latest Windows updates by first installing WuInstall.exe and adding this line.
WshShell.run "wuinstall.exe /install /reboot_if_needed"
And don't forget to do a quick defrag of the hard drive by adding the following lines to the script.
WshShell.run “Defrag volume c:”
WshShell.run "Defrag volume d:"
Automate Virus Scan After Cleanup
Last, but definitely not least, you'll also want to end your script by firing off a full virus scan. For example, I use Kaspersky, which offers its own set of command line parameters.
In my case, I just add the following final line to my script.
WshShell.run "AVP.exe SCAN /ALL /i4"
And that kicks off the command window and runs through a full scan (which can take several hours).
Most other anti-virus providers out there offer similar command-line options.
So, once you've added all of these lines, close out your Windows Script.
WScript.Quit
När du har avslutat proceduren ovan och sparat din fil på datorn, planera bara jobbet att köras regelbundet (/ Tillbehör / Systemverktyg / Uppgiftsschemaläggare). Ge proceduren ovanför ett försök och se hur bra det fungerar för dig.
Fungerade det bra, och kan du tänka på några andra användbara kommandoradsuppgifter som också kan läggas till? Dela dina tankar i kommentarfältet nedan.
Bildkredit: Shutterstock
Utforska mer om: Datorautomatisering, Datorunderhåll, Programmering.