Automation with AutoIT Tutorial: Part 2 - Technibble
Technibble
Shares

Automation with AutoIT Tutorial: Part 2

Shares

In part 1 of our Automation with AutoIT tutorial, we showed you how to run silent commands using AutoIT. In this article we are going to show you how to install applications that don’t have any silent install options. If you found the last article hard, don’t be turned off as this one is easier.

For this article I will be installing Winamp without using a silent switch.
Although inamp actually has a silent switch we will be doing it the other way sake of showing you how to do it for programs without them. This is where AutoIT really shines.

Note: This article assumes you have read part 1 of this article.
To begin, you need to create a blank .au3 file as mentioned in part of this series and name it appropriately. For the first step, we will run the install file using the following command:
Run("WinampInstall.exe")
In the last article we used the command “RunWait”. The difference between RunWait and Run is that Run wont wait until the application closes before going onto the next command. However, we do need to detect that the installer actually opened properly so we will be using the following command:
WinWaitActive("Installer Language")
This line causes the script wait until it sees a window titled “Installer Language” before going to the next line. The “Installer Language” window is the first Window we will see for the Winamp Install.

Now, imagine that you don’t have a mouse and can only use the keyboard. If we want to continue we would press ENTER to press OK. So we will send the ENTER key to the Winamp Installer.
Send("{ENTER}")

The next installer screen just lists the features of the newest Winamp version and we can just press the Next button by pressing ENTER to bypass this:
WinWaitActive("Winamp Installer")
Send("{ENTER}")

Now we are on the License Agreement page but the script needs to detect that we are actually on this screen by checking for a word that is on it. In this case the line “License Agreement” appears so we will tell the script to look for it using the following command:
WinWaitActive("Winamp Installer", "License Agreement")

All we need to do to for this stage is to press the “I Agree” button. So we will send the ENTER keystroke again to press the button.
Send("{ENTER}")

The next screen allows us to choose the install location. Once again, we need to detect we are actually on this screen so we use the following line:
WinWaitActive("Winamp Installer", "Choose Install Location")

The default location is “c:\Program Files\Winamp” but I would like to change this for examples sake, so I send the following text to the text field:
Send("C:\Applications\Winamp")
and press the Next button:
Send("{ENTER}")

Now we are on the page that allows us to choose the components that are going to be installed.

I usually install all of them when installing Winamp onto a clients computer so we are just going to press Next. If you want to deselect some options, I will show you how to do that in the next few steps, but for now all I am going to do is detect the screen and press next.
WinWaitActive("Winamp Installer", "Choose Components")
Send("{ENTER}")

The next page allows us to choose some start options, once again I will be leaving this is default and pressing Next.
WinWaitActive("Winamp Installer", "Choose Start Options")
Send("{ENTER}")

Now we are onto Winamp’s “Additional Features”. I don’t know about you but I hate these options because it installs a toolbar, changes your search provider and places an advertisement icon on your desktop, so I will be deselecting all of these.

Remember how I said to imagine that you don’t have a mouse? As you probably know the way to cycle through the options in an application is to press TAB.
So I need to press TAB once which will move the selector to the Cancel Button. Press it again to be on the “Winamp Remote” option and then press SPACE to deselect it.
Then press TAB again to get to the next one and press SPACE to deselect the Winamp Toolbar. I do this twice more to Deselect the Search option and the 50 free Mp3s option.
I press TAB again which takes me to the Back button and press TAB once more to get to the Install button. Once I am on the Install button I press ENTER.
WinWaitActive("Winamp Installer", "Get the Most Out of Winamp")
Send("{TAB}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}{ENTER}")

Winamp will start installing and we need to detect the “Installation Complete” text so we know when the installation has finished.
WinWaitActive("Winamp Installer", "Installation Complete")

Now we have one last option left, the “Launch Winamp after the installer closes” option. Since this article is about unattended installs, I am going to deselect it and press Finish:
WinWaitActive("Winamp Installer", "Installation Complete")
Send("{TAB}{SPACE}{ENTER}")

That’s it! Winamp should now be installed. Here is the complete code:

Run("WinampInstall.exe")
WinWaitActive("Installer Language")
Send("{ENTER}")
WinWaitActive("Winamp Installer")
Send("{ENTER}")
WinWaitActive("Winamp Installer", "License Agreement")
Send("{ENTER}")
WinWaitActive("Winamp Installer", "Choose Install Location")
Send("C:\Applications\Winamp")
Send("{ENTER}")
WinWaitActive("Winamp Installer", "Choose Components")
Send("{ENTER}")
WinWaitActive("Winamp Installer", "Choose Start Options")
Send("{ENTER}")
WinWaitActive("Winamp Installer", "Get the Most Out of Winamp")
Send("{TAB}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}")
Send("{ENTER}")
WinWaitActive("Winamp Installer", "Installation Complete")
Send("{TAB}{SPACE}{ENTER}")

I have created a thread in Technibbles forums and added the code used in this example which you can find here. I have also posted code samples on how to install .reg files and a few other tasks. I know many of you will be creating your own scripts after this tutorial, if we all share our scripts with one another we can build a nice collection of application install scripts for everyones benfit.

Go to the forum post >>

  • Nathan H says:

    Great Article, very helpful,

    Is there a way of getting AutoIT to download a program, example, Spybot, Adaware or AVG?

    then i could intall it and update it as discribed above

  • Bryce W says:

    Nathan, Win-get MIGHT work if you provide the full URL:
    https://www.technibble.com/deploy-software-with-winget/

  • Kj says:

    Hi all,

    If I was to install Winzip in French, as well as English how would I go about including both into 1 script? I seem to have drouble with this…

    Tried it with IF statements and “OR” but it doesn’t seem to do anything…

    Any suggestions would be appreciated!!!

    Thanks.

  • Cyberblood says:

    This is the script im triying to do but i cant figure out how to make adobe or flash work, i tried shellexecute, runwait, make it a .cmd but nothing it always tells me “windows cannot find the file” or it just dont do anything, i thing it has something to do with the fact that these files are *.msi.
    But the weird thing is that java install perfectly

    $Messenger_Location = “Apps\Install_Messenger\MsnMsgs.msi”
    $Adobe_Location = “Apps\Adobe\InstallAR.cmd”
    $java_Location = “apps\java\jre-6u6-windows-i586-p-s.exe /s /v /qn ADDLOCAL=ALL IEXPLORER=1 MOZILLA=1 REBOOT=Suppress JAVAUPDATE=1 EULA=1 /L C:\jre.log”
    $flash9_Location = “apps\install_flash_player_active_x.msi /qn”
    $googletoolbar_Location = “apps\GoogleToolbarInstaller.exe /q /d”

    ; Install Messenger Live
    If FileExists (@ProgramFilesDir & “\MSN Messenger”) Then
    MsgBox (64, “box” , “MSN is already installed”, 5 )

    Else
    ShellExecute($Messenger_Location)
    WinWaitActive(“Windows Live Messenger Setup Wizard”)
    Send(“{ENTER}”)
    WinWaitActive(“Windows Live Messenger Setup Wizard”, “Microsoft Service Agreement”)
    Send(“{TAB 4}{UP}{TAB}{ENTER}”)
    WinWaitActive(“Windows Live Messenger Setup Wizard”, “Choose additional features”)
    Send(“{TAB 5}{SPACE}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}”)
    WinWaitActive(“Windows Live Messenger Setup Wizard”, “successfully”)
    send(“{ENTER}”)
    EndIf

    ; Install Adobe Reader
    ShellExecute($Adobe_Location)

    ; Install Java
    Runwait ($java_Location)

    ; Install Flash9 for IE
    ShellExecute ($flash9_Location)

    ; Install Google Toolbar
    Runwait ($googletoolbar_Location)

    msgbox(64, “Done”, “Messenger, Adobe Reader, Java, Flash and Google toolbar Installed”) ; It will let you know when the script is done

    exit

  • berk says:

    very excellent

  • bodysoda says:

    i am new to autoit
    I am looking for script, that would setup pop account on outlook 2003.
    getting inputs email, pop server etc.
    any help would be appreciate.
    Thanks for the tutorial.

  • Tharindha says:

    Great work…..
    Very Helpful..

  • Anders says:

    Thanks for the guide!
    It was very helpful to me.

  • kel says:

    hi please send me or reply to this
    i need a continuous press of the numbers 123..

    is there a difference on the numbers on numpad and the numbers on top of QWERTY?

    kc13666@yahoo.com
    skypeID:kelvin_co

  • "HelloWorld" says:

    Just go to the forum on the autoit site for help and to see loads of great script examples
    http://www.autoitscript.com/forum/index.php?act=idx

  • carsnkrak says:

    update script to winamp other that choosing your skin after install. 10/13/10

    full file name
    winamp5581_full_emusic-7plus_en-us.exe

    Run(“WinampInstall.exe”)
    WinWaitActive(“Winamp Installer”)
    Send(“{ENTER}”)
    WinWaitActive(“Winamp Installer”, “License Agreement”)
    Send(“{ENTER}”)
    WinWaitActive(“Winamp Installer”, “Choose Install Location”)
    Send(“{ENTER}”)
    WinWaitActive(“Winamp Installer”, “Choose Components”)
    Send(“{ENTER}”)
    WinWaitActive(“Winamp Installer”, “Choose Start Options”)
    Send(“{ENTER}”)
    WinWaitActive(“Winamp Installer”, “Get the Most Out of Winamp”)
    Send(“{ENTER}”)
    WinWaitActive(“Winamp Installer”, “Installation Complete”)
    Send(“{ENTER}”)
    exit

  • >