This document outlines the process of creating and deploying a script using AutoIT. I use this software to automate application installers that do not install using the standard switches or require some form of user interaction at some point during the process. This software allows you to fully automate the install process but please note that some scripts can become very large so each script does require some testing before deployment.
This tutorial will provide a brief overview of how to program an automated script. You can use this software to a greater extent than discussed here but to ensure an installer works everytime I keep all my scripts simple. The process is pretty repetitive and can be tedious if the installer is lengthy. I would suggest running through the installer once to get the commands for the script, uninstall the application and then run the script to check if it works. You can always go back to the start if it doesn’t work and repeat the process.
Firstly, place the application in a folder on the deployment share or on the C:/ depending on where you intend to run the application from when installing.
Load up the application – SciTE Script Editor.
Save the new script immediately in the folder where the installer is located. This will save you later when getting the installer to start.
Type – #RequireAdmin (Gives the script admin rights)
Type – Run(“%Application_Name%”) – As the script is located in the same directory as the installer this automatically will pick up the installer name and run it.
Test this step by hitting F5 (This should start the installer). It is important to get this step correct in the first instance before continuing.
If successful the first dialog box will appear. Open AutoIt Window Info (x64 or x86 depending on the installer).
Change the coordinates – Options > Coord Mode > Change to Window as this will focus any command on the installer window rather than the screen. This means the installer can be open on any resolution display and will still work as the coordinates will be set to the installer window rather than the display.
To start the scripting process, drag the Finder Tool over the first button you want to click. You need to use the Window, Control and Mouse tabs to gather the information required for the script to run correctly.
Type: WinWait(“Paste Title”)
Type: WinActivate(“Paste Title”)
You can choose to use one of two commands: MouseClick or ControlClick. Note: that you will have to add AutoItSetOption(“MouseCoordMode”, 0) just after Run if using the MouseClick commands.
Type: MouseClick(“primary”, X, Y, 1, 0) – Primary Button, X and Y Position, 1 = Clicks, 0 = Speed.
or
Type: ControlClick(“Title”, “”, “[CLASS:Button; INSTANCE:%No%]”) – Title of the window, “” refers to left click on the mouse, Class and Instance indicates what class it is and its instance.
Test by hitting F5 (This should start the script and do the first command). You can keep the installer open and go through each step checking all the way through.
Note: If the command works the installer will move onto the next step. You can extend the process by adding Sleep (1000) after the previous action to allow the installer to catch up on screen.
Once the first process works you can just keep copy and pasting the base steps until all the steps of the installer have been scripted. You can then use the Exit command at the end to complete the process.
Save the script.
Note: You can use the Syntax Check function (Ctrl+F5) before compiling just to double check that the language is correct throughout the script. This will then check the script and detect any problems. This will give you an exit code 0 if successful.
Compile the script – Tools > Compile or press Ctrl+F7 to build the installer in the directory.
A new exe. file will then compile in the designated directory which you can then start the installer using the Command Prompt.
You can then run the installer from the directory and watch it install. I suggest doing this on a different PC so you can see how it works on a new PC as it would be during deployment.
Below is an example of an application being deployed using AutoIt. The script is based on the LTSpice installer I use. If you want to try this script, create a folder on your desktop and save this script and the LTspice installer into the same folder.
#RequireAdmin
Run(“LTspiceXVII.exe”)
WinWait(“LTspice XVII Installer”)
WinActivate(“LTspice XVII Installer”)
ControlClick(“LTspice XVII Installer”, “”, “[CLASS:Button; INSTANCE:4]”)
Sleep(1000)
WinWait(“LTspice XVII Installer”)
WinActivate(“LTspice XVII Installer”)
ControlClick(“LTspice XVII Installer”, “”, “[CLASS:Button; INSTANCE:1]”)
Sleep(1000)
WinWait(“LTspiceXVII”)
WinActivate(“LTspiceXVII”)
ControlClick(“LTspiceXVII”, “”, “[CLASS:Button; INSTANCE:1]”)
Sleep(1000)
WinWait(“Web Sync”)
WinActivate(“Web Sync”)
ControlClick(“Web Sync”, “”, “[CLASS:Button; INSTANCE:2]”)
Sleep(1000)
WinWait(“LTspice XVII”)
WinActivate(“LTspice XVII”)
WinKill(“LTspice XVII”)
Exit
Note: The LTSpice application begins at the end of the install process so I use WinKill to close the application before exiting the script.
To start the installer create a cmd file and run it as an admin.
@ECHO off
TITLE Install LTSpice
CLS
ECHO.
ECHO Installing LTSpice…
start “LTSpice” /wait C:\LTSpice\LTSpice_Install.exe
The application should successfully run from the Command Prompt and install LTSpice. I will add a few more examples of AutoIt Installations in future posts.
