In our last “computer repair tool of the week” article we posted about the application called Universal Silent Switch Finder which has the ability to find hidden install switches. The advantage of knowing what these hidden switches are is that it allows you to control the way a piece of software is installed. For example, if we were to install something like Spybot and we used its “silent” switch, it would install Spybot without ever showing us an install screen or asking us any questions. The main advantage of this is that it allows us to automate what we do.
Lets say that you install a certain set of software on every system that you sell like Spybot, Ad-Aware and AVG antivirus. You can make this a 1 click process and let the application that you created do all the work. In this article, we’ll show you how to do it.
We will be making our automation application using a tool called AutoIT. AutoIT is a basic scripting language which is easy to learn but does require a little bit of coding knowledge.
Introduction to AutoIT
To begin, download AutoIT HERE and install it.
In a folder of your choice, create a new text document (right click in a open area, go to New > Text Document). You can name it whatever you want but change the extension to .au3 . This is the scripting file that AutoIT will be using and where we will be placing our code. You can open this file with any text editor but AutoIT also comes with a special editor that makes things a little easier.
If you right click on your new .au3 file, there will be three new options: Compile Script, Edit Script and Run Script. Choose Edit Script.
You should see the contents of an empty file that looks like a blank text file, this is where we will be placing our code.
To begin with a very basic script, enter the following line into your script file and click save.
RunWait("C:\WINDOWS\system32\defrag.exe C: -f")
Below that line, also add:
This command starts a defrag of the C: drive and the -f switch forces a defragmentation even if the free space is low. If you ran this command in DOS yourself, you would get the exact same outcome. You can also try this with many other DOS commands. As for the exit line, it just tells the script to close when its finished.
Now we know what it does, right click on your .au3 file and choose “Run Script”. You should see the DOS window show up and it will start defragging the C: drive.
The problem with .au3 files is that the “Run Script” option wont show up on other computers unless they have AutoIT installed so we need to compile the script to make it portable. Right click on your .au3 file again and choose “Compile Script”. This will create an .exe version of your script.
So if you have named your au3 script mycode.au3, there will now be a file called mycode.exe. This has made our script portable and can be run on any Windows computer.
For this automated install example, we’ll be installing the popular compression software 7zip which you can download here.
Once it has been downloaded, we need to find out which “switch” tells the 7zip installer to install silently so that it doesn’t show us the setup menu. To do that, we can use Universal Silent Switch Finder which you can download here.
Run Universal Silent Switch Finder, press the > button and find the 7zip install. It will then fill out the “Usage” field which should be “7z457.exe” /S which means /S is our “silent switch”.
Clear out your old .au3 scripts or start a new one and add:
RunWait("7z457.exe /S ")
This script assumes that the 7zip installer is in the same directory as the script.
Note: Be careful with the quotation marks because the line from USSF and the line needed in the code have them in different places.
Run this script and if you did it correctly, it will appear that nothing has happened. Check your Start Menu or the Program Files folder and you should see at 7zip has been installed.
To add mutliple applications to be automatically installed you would do something like:
RunWait("7z457.exe /S ")
RunWait("AVG8.exe /s ")
Automating the Running of Applications
AutoIT doesnt just limit you to just automating the install of an application, you can also automate the running of them too.
For example, we can tell an application like Clamwin which a portable virus scanner, to scan the C drive for viruses and once they are found, delete them, using the following line
RunWait("ClamWin.exe --mode=scanner --path=c: --remove --close")
To find the command line switches for different applications, try the applications documentation or search for them on Google.
That’s it for part 1 and we have barely scratched the surface with what AutoIT is capable of, in part 2 of our AutoIT article we’ll show you how to automate an installation of an application that doesn’t have install switches and how to install registry tweaks. For additional help with what we have worked with here, AutoIT has some great documentation.
Special thanks to our forum member focuz, who sent in many of his AutoIT automation examples which much of this article is based off.