Novell Home

AppNote: Enhancing ZENworks Desktop Management with AutoIt

Novell Cool Solutions: AppNote
By Eugene Phua

Digg This - Slashdot This

Posted: 28 Jun 2007
 

1.Introduction

If you have been using ZENworks to roll out applications, you will be aware that unless the applications come with "silent install mode" or as a MSI, you will be requiring AOT to install the application. Currently the shortcomings of AOT (in my humble opinion) are as follows:

  • Creating an AOT application can be time-consuming especially for large applications.
  • AOT creates a large number of files. On occasions where one of the files is corrupted, you have to recreate AOT applications.
  • The AOT files cannot be reused. For example, if you have rolled out Application v1.0 and now you want to roll out Application v1.1, you have to redo the entire AOT process. You cannot reuse the Application v1.0 files.

AutoIt is one way to overcome the above shortcomings. This documentation seeks to introduce AutoIt to the uninitiated and so the examples written can be repetitive and simple. One thing to note is that this documentation is not solely about AutoIt. The purpose of this documentation is to introduce a useful tool that can be integrated with ZENworks so that your life as an administrator can be made easier.

2. What does this document hope to accomplish?

This AppNote is written with the following objectives in mind:

  • Provide simple examples to AutoIt scripting to install programs without user intervention
  • Provide simple examples as to how AutoIt can be integrated with ZENworks.

3. What is AutoIt?

AutoIt v3 is a freeware scripting language designed for automating the Windows GUI. It uses a combination of simulated keystrokes, mouse movement and window control manipulation in order to automate tasks. This means that you can automate the installation of any program by allowing AutoIt to simulate the 'Next' and 'Finish' keystrokes so that the program can be installed without user intervention. AutoIt is also very small, self-contained and will run on 95, 98, ME, NT4, 2000, XP, 2003 out of the box with no annoying "runtimes" required!

Download AutoIT here.

During the time this document was written, the version of AutoIt is version 3.2.4.9. So download AutoIt v3 and we can start familiarizing with the software.

I will also highly recommend looking through the AutoIt documentation.

4.Getting familiarized with AutoIt

4.1 Installing AutoIt

After downloading AutoIt v3, run the "autoit-v3.2.4.9-setup.exe" installation file. Accept all options as default.

4.2 AutoIt Script Editor

Now that AutoIt has been installed, go to 'Start' > Programs > AutoIt v3 > SciTE Script Editor

This will open the script editor from which you can write your script. We will do this later.

4.3 Au3info tool

AutoIt comes with an Au3info tool that gives you information about Windows. Since AutoIt is about controlling Windows behaviour, we want to know Windows information so that we can send the correct keystrokes or information to manipulate Windows behaviour.

Au3info tool can be activated by running => C:\program Files\AutoIt3\Au3Info.exe

We will talk more about this tool when we are creating an advance AutoIt script.

Get more information on the Au3info tool here

4.4 Running an AutoIt script

AutoIt provides sample scripts so that you can view the script and run it to get a feel of how AutoIt works. The scripts are located in C:\Program Files\AutoIt3\Examples.

Right-click on any one of the scripts provided (e.g. calculator.au3) and choose to 'Run Script'. Impressive, isn't it?

Right-click on any one of the scripts provided (e.g. calculator.au3) and choose to 'Edit Script'. AutoIt Script Editor pops to show you the (easy looking) script that did all those impressive things.

Right-click on any one of the scripts provided (e.g. calculator.au3) and choose to 'Compile Script'. An .exe file is created. You can take this file and run it on any Windows workstation and it will run perfectly fine without any additional "runtimes" required. Wonderful, isn't it?

So now that you are familiarized with AutoIt, we can use AutoIt to install an program.

5. A Simple AutoIt example: Using AutoIt to install VLC player

I am using VLC player as an example because firstly I think this is wonderful (and free) software. But more importantly, it does not have MSI or Silent Install option which means that the only way to get it installed is by clicking a series of 'Next' and 'Finish'. We will be using AutoIt to avoid that.

You can download VLC player from
(As of the time of this documentation, the VLC player version is 0.8.6b). For the sake of simplicity, download the VLC file to the C:\ drive.

(**Note: Please note that for sake of simplicity, all installation files are copied to the C:\. In actual implementation, because the users may not have rights to the root of C:\ drive, you may have to copy the installation files to another location. This is explained in a later section.)

Once you downloaded the VLC installer file (vlc-0.8.6b-win32.exe), simulate the installation of the VLC player without actually installing it, that is, click 'Next' until you reach the 'Install' button then press 'Cancel' . You will observe the following Windows dialog boxes appear:

  • Windows Title: Installer Language. English Default. Press 'Enter' key to continue.
  • Windows Title: VideoLAN VLC media player 0.8.6b Setup. Welcome. Press 'Enter' key to continue.
  • Windows Title: VideoLAN VLC media player 0.8.6b Setup. License Agreement. Press 'Enter' key to continue.
  • Windows Title: VideoLAN VLC media player 0.8.6b Setup. Choose Component. Press 'Enter' key to continue.
  • Windows Title: VideoLAN VLC media player 0.8.6b Setup. Choose install Location. Press 'Enter' key to start installation.

Based on the above simulation, we know that in order to install VLC, we need to press 'Enter' five times.

(**Note: If you are already familiar with AutoIt or you think that the following AutoIt examples are too simple, you can skip to section 7 and compile the script documented there. The script in the "Customizing VLC install with AutoIt script" section is the final script we will be using with ZENworks but I wanted to take things one step at a time. Hence we will be going through two scripts before getting to the final one.)

5.1 A simple AutoIt script

As a simple example, if we want to install VLC with all the default settings, the following AutoIt Script will do the job.

; Simple AutoIt script 

; Run the install 
Run("C:\vlc-0.8.6b-win32.exe")

; Choose Installer Language
WinWaitActive("Installer Language")
Send("{ENTER}") 

; Welcome Screen
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup")
Send("{ENTER}") 

; License Agreement
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup")
Send("{ENTER}") 

; Choose Components
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup")
Send("{ENTER}") 

; Choose Install Path
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup")
Send("{ENTER}") 

Even if you have never done scripting in your life, you can very easily tell that all that the script is doing is to wait for each Windows to become active and then send a {ENTER} keystroke to the window. The script sends 5 {ENTER} keystrokes to start the installation.

Now do the following to create an executable file to automatically install VLC player.

  1. Open ScITE editor and copy the above script into the editor. Save the script as "C:\vlcinstall.au3.
  2. Right-click on C:\vlcinstall.au3 and choose to compile. Vlcinstall.exe is created.
  3. Run vlcinstall.exe. VLC player is installed automatically.

The vlcinstall.exe should install the vlc player for you. However, right at the end of the installation, you will see the 'Install completion' screen. It is not very elegant to expect users to close this window after installation.


We want to close this window and not run VLC player after installation. In order to do this, we need to use the Au3info tool.

6. Au3info tool

The problem with the simple AutoIt script.

Now is time to tell you about a problem in the simple AutoIt script. The simple screen does not identify each window as unique. Each window is identified as "VideoLAN VLC media player 0.8.6b Setup". This isn't a problem until we want to close the last screen. Now you could try including the additional lines in the script and try to run the script again:

WinWaitActive("VideoLAN VLC media player 0.8.6b Setup")
Send("{ENTER}")

But it will not work. The reason is because prior to this "Installation Complete" window, the VLC installation "progress" window was running and that window has the same name "VideoLAN VLC media player 0.8.6b Setup". So the above command will be sending {ENTER} keystroke to the VLC installation "progress" window. The trick is to identify each window to be unique and so that the appropriate command will be send to correct Windows. To do this, we need the Au3info tool.

6.1 Using the Au3Info tool

We have to uninstall the VLC and reinstall it (sorry). This can be easily done by running the C:\vlc-0.8.6b-win32.exe again.

To use Au3Info.exe tool to identify each window as unique, do the following:

  1. When the first installation screen appears, open the C:\program Files\AutoIt3\Au3Info.exe tool
  2. From the Au3Info window, choose the 'Visible Text' tab.
  3. Go back to the first VLC installation window, highlight on the title of the installation window (Installer Language) as shown below:

  4. You will notice a number of key words such as: 'OK' and 'Please select a language".
  5. Do this for every installation window for the VLC installation.

You may have taken note of the following windows and key words:

  • "Choose Installer Language" Window.
    Keywords: "Installer Language", "Please select a language", "Ok"
  • "Welcome Screen" Window.
    Keywords: "VideoLAN VLC media player 0.8.6b Setup", "Welcome to the VideoLAN VLC media player 0.8.6b Setup Wizard", "&Next"
  • "License Agreement" Window.
    Keywords: "VideoLAN VLC media player 0.8.6b Setup", "License Agreement", "I &Agree"
  • "Choose Components" Window.
    Keywords: "VideoLAN VLC media player 0.8.6b Setup", "Choose Components", "&Next"
  • "Choose Install Path" Window.
    Keywords: "VideoLAN VLC media player 0.8.6b Setup", "Choose Install Location", "&Install"
  • "Installation Complete" Window.
    Keywords: "VideoLAN VLC media player 0.8.6b Setup", "Click Finish to close this wizard", "&Finish"

Now you have enough keywords to make each windows unique. Therefore, you can make modifications to the script as follows:

; AutoIt script that installs VLC with default settings

; Run the install
Run("C:\vlc-0.8.6b-win32.exe")

; Choose Installer Language
WinWaitActive("Installer Language", "Please select a language", "Ok")
Send("{ENTER}") 

; Welcome Screen
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup", "Welcome to the VideoLAN VLC media player 0.8.6b Setup Wizard",  "&Next")
Send("{ENTER}") 

; License Agreement
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup", "License Agreement", "I &Agree")
Send("{ENTER}") 

; Choose Components
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup", "Choose Components", "&Next")
Send("{ENTER}") 

; Choose Install Path
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup", "Choose Install Location", "&Install")
Send("{ENTER}") 

; Installation Complete
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup", "Click Finish to close this wizard", "&Finish")
Send("!f")

As you can see, this new script identified each windows uniquely as compared to the previous script. Another thing noteworthy is at the final window, an "Alt-F" keystroke was sent to finish the installation. This is done with a 'Send("!f")' command. You can now try to compile the script and do an install of the application.

7. Customizing VLC install with AutoIt script

What we have done so far is to accept the default setting of the VLC installation. We want to modify the VLC installation with the following settings:

  • We want to install Mozilla plugin.
  • When the installation reaches the "Choose Component" window, the following keystrokes will select the Mozilla plugin component: Tab > Down > Down > Down > Down > Space.
  • We do not want to run VLC player after installation.
    When the installation reaches the "Installation Complete" window, an "Alt-R" keystroke will uncheck the option to run the VLC program.

Through these simple keystrokes, we have our final script to install VLC player. You can test the script by compiling the new script and installing the VLC player with it. You can take the vlcinstall.exe and vlc-0.8.6b-win32.exe files to any Windows 2000 or XP workstation and it will run.

; AutoIt script that installs VLC with customized settings

; Run the install 
Run("C:\vlc-0.8.6b-win32.exe")

; Choose Installer Language
WinWaitActive("Installer Language", "Please select a language", "Ok")
Send("{ENTER}") 

; Welcome Screen
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup", "Welcome to the VideoLAN VLC media player 0.8.6b Setup Wizard",  "&Next")
Send("{ENTER}") 

; License Agreement
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup", "License Agreement", "I &Agree")
Send("{ENTER}") 

; Choose Components
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup", "Choose Components", "&Next")
Send("{TAB}") 
Send("{DOWN}") 
Send("{DOWN}") 
Send("{DOWN}") 
Send("{SPACE}") 
Send("{ENTER}") 

; Choose Install Path
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup", "Choose Install Location", "&Install")
Send("{ENTER}") 

; Installation Complete
WinWaitActive("VideoLAN VLC media player 0.8.6b Setup", "Click Finish to close this wizard", "&Finish")
Send("!r")
Send("!f")

8. Integrating everything together with ZENworks

To integrate with ZENworks, you will need the following two files:

  • VLC install file (vlc-0.8.6b-win32.exe)
  • AutoIt executable file (vlcinstall.exe)

Let's assume that you have an application server with the following configuration:

IP address: 10.1.1.1
Vol: apps
VLC install directory: vlc

Copy the vlc-0.8.6b-win32.exe and the vlcinstall.exe to the application server at the following location:
\\10.1.1.1\apps\vlc.

(**Note: Make sure that you assign the appropriate rights to this location so that users can install from this location.)

8.1 Create a VLCinstall batch

In the same location, create the following dos-batch file (e.g. vlcinstall.bat) with the following content:

REM copies the content of the vlc executable files to c:\ drive
copy \\10.1.1.1\apps\vlc\vlc*.exe c:\

REM run the VLCinstall file
c:\vlcinstall .exe

REM deletes the installation file after install. 
Del C:\vlc*.exe 

The above is a simple batch that does the following:

  • Copies the vlcinstall.exe and vlc-0.8.6b-win32.exe to the local drive
  • Runs the vlcinstall.exe that was compiled in the previous section
  • Deletes the vlcinstall.exe and vlc-0.8.6b-win32.exe from the local drive after installation completes

8.2 Create a NAL application

Create a NAL application with the following settings:

  1. Define the NAL application as a simple application

  2. Define the name of the NAL application (e.g. VLCinstall)

  3. Define the path of the Application file (e.g. \\10.1.1.1\apps\vlc\vlcinstall.bat). The file is pointing to the batch created earlier.

  4. Define the availability of the object. In this example, I configure the availability for WinXP SP2 workstation and if the VLC registry key does not exist (that is, VLC player is not installed on that workstation).

  5. Define the user association. I set the NAL object to force run and appear at the App Launcher.

  6. Click Finish to complete the installation.

8.3 Rolling NAL application to users without administrators rights.

To roll NAL applications to users without administrator rights, you can set the NAL application to run as "Unsecure System User". There are several things to take note of:




  • AutoIt applications cannot run as "Secure System User" because AutoIt requires the Windows to be active and in the foreground. "Secure System User" mode hides the installation Windows in the background.
  • In order for applications to run as "Unsecure System User", the user's workstation must be imported and workstation object has effective read and file scan rights to the Netware directory that the application object is running the executable from. See the TID 10014516 for more details
  • Determine whether the users have access to the root of the C:\ drive. In this documentation, to make the examples easy, the installation path has been set to the C:\ drive. You may have to determine a path where all users have rights and change your scripts accordingly to point to the correct path.

9. Conclusion

As with everything else, it may take a little time to get use to AutoIt. But the great thing is that once you are familiarized with AutoIt, it should take you no time to write a script to install an application. Best of all, when you want to upgrade the applications, you can reuse the scripts with minor modifications. Using AutoIt with ZENworks will make rolling out of applications really easy and hopefully, fun.

**My personal thanks to Andy Wu, Senior IT Consultant from Hong Ti Information Consultant LTD. for introducing me to AutoIt.


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell