Jump to content

Recommended Posts

Posted

Hi everyone. i'm pretty much new with autoit and programming in general but i do hope you can help me. i want to install and do three things to more than 2000 computers here in our company. What I want to do is to install Adobe 9.30. After the installation, I'll run the patch and then after that open it up and do some configuration inside before restarting the PC. I was able to make those three tasks individually but I'm unable to make them work under one autoit exe file.

Here's what happens. The first installation is going smoothly. However after that finishes, the script just pauses and doesn't go over to the next installation process (which is to update the patch). I've tried first to have the script Sleep for a few seconds before the next installation but it won't go forward. I made the three into functions but the results are the same. If anyone can help me I'd really really really appreciate it.

here's my script by the way:

Call ("adobe1")
Sleep(5000)
Call ("adobe2")
Sleep(5000)
Call("adobe3")

Func adobe1()

Run('AdbeRdr930_en_US.exe')
WinWait("Adobe Reader 9.3 - Setup","Change &Destination ")
If Not WinActive("Adobe Reader 9.3 - Setup","Change &Destination ") Then WinActivate("Adobe Reader 9.3 - Setup","Change &Destination ")
WinWaitActive("Adobe Reader 9.3 - Setup","Change &Destination ")
Send("{ENTER}")
WinWait("Adobe Reader 9.3 - Setup","Click Install to beg")
If Not WinActive("Adobe Reader 9.3 - Setup","Click Install to beg") Then WinActivate("Adobe Reader 9.3 - Setup","Click Install to beg")
WinWaitActive("Adobe Reader 9.3 - Setup","Click Install to beg")
Send("{ENTER}")
WinWait("Adobe Reader 9.3 - Setup","Setup has successful")
If Not WinActive("Adobe Reader 9.3 - Setup","Setup has successful") Then WinActivate("Adobe Reader 9.3 - Setup","Setup has successful")
WinWaitActive("Adobe Reader 9.3 - Setup","Setup has successful")
Send("{ENTER}")
WinWait("setup","Setup needs to resta")
If Not WinActive("setup","Setup needs to resta") Then WinActivate("setup","Setup needs to resta")
WinWaitActive("setup","Setup needs to resta")
Send("{RIGHT}{ENTER}")

EndFunc

Func adobe2()
ShellExecute("AdbeRdrUpd932_all_incr.msp")
WinWait("Adobe Reader 9.3.2 Patch","The InstallShield(R)")
If Not WinActive("Adobe Reader 9.3.2 Patch","The InstallShield(R)") Then WinActivate("Adobe Reader 9.3.2 Patch","The InstallShield(R)")
WinWaitActive("Adobe Reader 9.3.2 Patch","The InstallShield(R)")
Send("{ENTER}")
WinWait("Adobe Reader 9.3.2 - Setup","Setup has successful")
If Not WinActive("Adobe Reader 9.3.2 - Setup","Setup has successful") Then WinActivate("Adobe Reader 9.3.2 - Setup","Setup has successful")
WinWaitActive("Adobe Reader 9.3.2 - Setup","Setup has successful")
Send("{ENTER}")

EndFunc

Func adobe3()
Run('C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe')
WinWait("Adobe Reader - License Agreement","")
If Not WinActive("Adobe Reader - License Agreement","") Then WinActivate("Adobe Reader - License Agreement","")
WinWaitActive("Adobe Reader - License Agreement","")
Send("{ENTER}")
WinWait("Decline License Agreement","")
If Not WinActive("Decline License Agreement","") Then WinActivate("Decline License Agreement","")
WinWaitActive("Decline License Agreement","")
Send("{ENTER}")
WinWait("Adobe Reader - License Agreement","")
If Not WinActive("Adobe Reader - License Agreement","") Then WinActivate("Adobe Reader - License Agreement","")
WinWaitActive("Adobe Reader - License Agreement","")
Send("{RIGHT}{ENTER}")
WinWait("Adobe Reader","")
If Not WinActive("Adobe Reader","") Then WinActivate("Adobe Reader","")
WinWaitActive("Adobe Reader","")
Send("{CTRLDOWN}k{CTRLUP}")
WinWait("Preferences","")
If Not WinActive("Preferences","") Then WinActivate("Preferences","")
WinWaitActive("Preferences","")
Send("{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{TAB}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{DOWN}{TAB}{SPACE}{TAB}{ENTER}")
Sleep(3000)
Shutdown(6)
EndFunc

Exit

This was made from Scite Scriptwriter so pardon the silliness. I attempted to create an all original but my brain kind of failed me. :idea:

Posted (edited)

Hello,

Add this to the top of your script:

Opt("trayIconDebug", 1)

When it pauses.

Hold your mouse over the icon (in system tray) and see what it says there.

It should tell you where its getting stuck.

if you need further help, let us know.

Steve

Edited by Steveiwonder

They call me MrRegExpMan

Posted

thank you for the reply sir. I'll do that first thing I get to office on Monday. I can't run the script from my home PC. VPN's kinda wonky.

Posted

I'd suggest sticking some MsgBox markers to localize the point of failure in the script.

I've looked the script over and I can't see much of what could be a problem. The only thing that raises a flag to me is the Send("{RIGHT}{ENTER}"). I'm not exactly sure what happens there, whether {RIGHT} and {ENTER} are pressed simultaneously or one after the other, which is usually why I try to split my Send(s) just for clarity.

Posted

Hi steve, I've added the line on the script and it didn't seem to show me where it got stuck. Actually what I noticed is that it's not paused like how autoit pauses with a blinking X mark. it just stops entirely. when I click on the icon, well, that's when it really pauses (with the blinking X).

hi omikron48. the {RIGHT}{ENTER} there is just so the PC won't restart after installation of the first version of adobe. the option was default to the option yes. So I had to press right then enter to avoid a reboot.

hi volly, thanks for the PM.

Posted (edited)

For the educational side of your issue, I would assume that your installation process is still running when the msiexec patch executes which could cause the patch process to terminate early. ProcessWaitClose() may help solve the issue for you. I made some various changes and the comments may help for you to understand.

; shows current line processed when mouse cursor hovers over the tray icon
Opt("TrayIconDebug", True)

; proceed if _adobe1() is non zero or not false (i.e. something)
If adobe1() Then
    Sleep(5000)
    adobe2()
    ; you can also check return of UDF error this way using @error
    If @error Then
        ConsoleWrite('_adobe2() returned error ' & @error & @CRLF)
    EndIf
    Sleep(5000)
    If adobe3() Then
        ; moved shutdown here in clear sight
        Shutdown(6)
    Else
        ConsoleWrite('_adobe3() returned bool error' & @CRLF)
    EndIf
Else
    ConsoleWrite('_adobe1() returned bool error' & @CRLF)
    ; exit with code 1 on failure
    Exit 1
EndIf

Exit

Func adobe1()
    Local $pid
    ; return ProcessID to use in ProcessWaitClose
    $pid = Run('AdbeRdr930_en_US.exe')
    ; check error else not worth processing windows
    If Not @error Then
        WinWait("Adobe Reader 9.3 - Setup", "Change &Destination ")
        ; removed "If WinActive() Then" as just WinActivate() should be enough normally
        WinActivate("Adobe Reader 9.3 - Setup", "Change &Destination ")
        WinWaitActive("Adobe Reader 9.3 - Setup", "Change &Destination ")
        Send("{ENTER}")
        WinWait("Adobe Reader 9.3 - Setup", "Click Install to beg")
        WinActivate("Adobe Reader 9.3 - Setup", "Click Install to beg")
        WinWaitActive("Adobe Reader 9.3 - Setup", "Click Install to beg")
        Send("{ENTER}")
        WinWait("Adobe Reader 9.3 - Setup", "Setup has successful")
        WinActivate("Adobe Reader 9.3 - Setup", "Setup has successful")
        WinWaitActive("Adobe Reader 9.3 - Setup", "Setup has successful")
        Send("{ENTER}")
        ; odd the "setup" title is not capitalized. i.e. "Setup"
        WinWait("setup", "Setup needs to resta")
        WinActivate("setup", "Setup needs to resta")
        WinWaitActive("setup", "Setup needs to resta")
        Send("{RIGHT}{ENTER}")
        ; wait for process to close (else following patch may fail if this is still running)
        ProcessWaitClose($pid)
        Return True
    EndIf
    ; return @error = 1, @extended = 0 and value = False
    Return SetError(1, 0, False)
EndFunc

Func adobe2()
    ShellExecute("AdbeRdrUpd932_all_incr.msp")
    If Not @error Then
        WinWait("Adobe Reader 9.3.2 Patch", "The InstallShield®")
        WinActivate("Adobe Reader 9.3.2 Patch", "The InstallShield®")
        WinWaitActive("Adobe Reader 9.3.2 Patch", "The InstallShield®")
        Send("{ENTER}")
        WinWait("Adobe Reader 9.3.2 - Setup", "Setup has successful")
        WinActivate("Adobe Reader 9.3.2 - Setup", "Setup has successful")
        WinWaitActive("Adobe Reader 9.3.2 - Setup", "Setup has successful")
        Send("{ENTER}")
        Return True
    EndIf
    Return SetError(2, 0, False)
EndFunc

Func adobe3()
    Local $pid
    ; added double quotes and changed to using @ProgramFilesDir if suitable
    $pid = Run('"' & @ProgramFilesDir & '\Adobe\Reader 9.0\Reader\AcroRd32.exe"')
    If Not @error Then
        WinWait("Adobe Reader - License Agreement", "")
        WinActivate("Adobe Reader - License Agreement", "")
        WinWaitActive("Adobe Reader - License Agreement", "")
        Send("{ENTER}")
        WinWait("Decline License Agreement", "")
        WinActivate("Decline License Agreement", "")
        WinWaitActive("Decline License Agreement", "")
        Send("{ENTER}")
        WinWait("Adobe Reader - License Agreement", "")
        WinActivate("Adobe Reader - License Agreement", "")
        WinWaitActive("Adobe Reader - License Agreement", "")
        Send("{RIGHT}{ENTER}")
        WinWait("Adobe Reader", "")
        WinActivate("Adobe Reader", "")
        WinWaitActive("Adobe Reader", "")
        Send("{CTRLDOWN}k{CTRLUP}")
        WinWait("Preferences", "")
        WinActivate("Preferences", "")
        WinWaitActive("Preferences", "")
        ; you can shorten "{DOWN}{DOWN}" to "{DOWN 2}" for example
        Send("{DOWN 7}{TAB}{SPACE}{SHIFTDOWN}{TAB}{SHIFTUP}{DOWN}{TAB}{SPACE}{TAB}{ENTER}")
        Sleep(3000)
        Return True
    EndIf
    Return SetError(3, 0, False)
EndFunc

That is nice for learning automation of the GUI for installs but you are looking after 2000 PCs which may need a more reliable solution. If silent install switches exists then I recommand the use of them unless you have special needs. So you can search Google for silent install adobe reader 9.3. The 1st link here at the "Command Lines" section of the page shows how to handle the install using switches which can make the install silent, accept the eula and choose if reboot is preferred. You can do it all with an AutoIt script by using switches to the installer and it will be less lines and more reliable.

So if I take a command from the link, the script could be this:

$exitcode = RunWait('"AdbeRdr930_en_US.exe" /sAll /rs /l ' & _
            '/msi"/qb /norestart ALLUSERS=1 ' & _
            'EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES"')

I notice that it is missing the patch in the CLI though the page mentions an ini file which can be used. Some more research may yield results that may you perfect.

Edit:

changed/removed a couple of words

added missing double quote in last CLI

Edited by MHz
Posted

everyone thank you very much for all the help! I finally found the problem as to why it just pauses. It turns out that some of our PC's doesn't have a previous version of adobe. without this, the prompt for the reboot doesn't occur making my program pause as it waits for the window to become active.

I've ran the program to a PC with a previous version of adobe and it went with no problems. Sorry for giving everyone headaches. But your advices won't go to waste. I've definitely learned from them a great deal.

again thanks!

Posted

Well, good thing you figures it out then.

I made installation scripts too some months ago. In my case, I only scripted for normal installations with no prior programs installed, since I was mainly installing on new workstations bought from the vendor. I just made some simple utility tools to help with my work. I made a script that used a settings file with all my installations listed. It allows me to select which programs are to be installed and then it runs the scripts sequentially. All that was left for me to do with a new workstation was just check which programs are already installed then select what else is needed. I just left my script running until all the installations are done.

Posted

Well, good thing you figures it out then.

I made installation scripts too some months ago. In my case, I only scripted for normal installations with no prior programs installed, since I was mainly installing on new workstations bought from the vendor. I just made some simple utility tools to help with my work. I made a script that used a settings file with all my installations listed. It allows me to select which programs are to be installed and then it runs the scripts sequentially. All that was left for me to do with a new workstation was just check which programs are already installed then select what else is needed. I just left my script running until all the installations are done.

I wouldn't mind seeing your script. I have a similar script I made ages ago and still use. It isn't worth sharing as it grew (no planning), it works but I'd be embarrassed for anyone to see. :idea:

Posted

This is my "launcher" script. It allows you to generate a list from an ini file and select which item you want run. The only limitation it has is that you can't rearrange the execution order of the items on the fly. Still haven't figured out how to do that yet. It could possibly involve tables, arrays and button controls.

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <TreeViewConstants.au3>
_Singleton("Automated Launcher Script")
Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
HotKeySet("^!x", "_Close");Exit on Ctrl+Alt+X

Global $ininame = "_process_launcher.ini"

If $CmdLine[0] == 1 Then
    $ininame = $CmdLine[1]
EndIf

If Not FileExists($ininame) Then
    MsgBox(0x2030, "Error", "No """ & $ininame & """! Writing empty .ini file.")
    _CreateINI()
    Exit
EndIf

Global $slist = IniReadSectionNames($ininame)
If @error == 1 Then
    MsgBox(0x2030, "Error", "Read fail for " & $ininame & "! File empty or invalid.")
    Exit
EndIf
Global $guiWindow = GUICreate("Process Queue", 250, 250)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
Global $guiButton = GUICtrlCreateButton("OK", 85, 210, 80, 30, $BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent($guiButton, "_ButtonEvent")
Global $guiLabel = GUICtrlCreateLabel("Choose programs to Install:", 10, 10, 180, 15)
Global $guiTree = GUICtrlCreateTreeView(10, 30, 230, 175, $TVS_CHECKBOXES)
Global $tItem[$slist[0] + 1]
For $i = 1 To $slist[0]
    $tItem[$i] = GUICtrlCreateTreeViewItem($slist[$i], $guiTree)
Next
GUISetState(@SW_SHOW)

Sleep(86400000)

Func _ButtonEvent()
    Local $msgres = MsgBox(0x2124, "Confirm Selection", "Are you sure of your selection?", 86400, $guiWindow)
    If $msgres == 6 Then
        GUISetState(@SW_HIDE)
        Local $pID, $path, $dir, $checked = False
        For $i = 1 To $slist[0]
            If BitAND(GUICtrlRead($tItem[$i]), $GUI_CHECKED) Then
                $checked = True
                $path = IniRead($ininame, $slist[$i], "path", "<no path>")
                $dir = IniRead($ininame, $slist[$i], "dir", ".\")
                $pID = Run($path, $dir, @SW_HIDE)
                If @error <> 0 Then
                    MsgBox(0x2030, "Error", "Failed to run " & $slist[$i] & ": """ & $path & """!", 86400, $guiWindow)
                EndIf
                ProcessWaitClose($pID)
            EndIf
        Next
        GUISetState(@SW_SHOW)
        If $checked Then
            MsgBox(0x2000, "Process Launcher", "Process queue finished!", 86400, $guiWindow)
            _Close()
        Else
            MsgBox(0x2000, "Process Launcher", "No process selected!", 86400, $guiWindow)
        EndIf
    EndIf
EndFunc

Func _CreateINI()
    Local $file = FileOpen($ininame, 2)
    FileWriteLine($file, ";INI file for Process Launcher")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";INI file format is:")
    FileWriteLine($file, ";[SECTION]")
    FileWriteLine($file, ";KEY = VALUE")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Section name is label for installation script.")
    FileWriteLine($file, ";Key(s) are: Path, Dir")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Processes are launched in succeeding order, one at a time.")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Sample:")
    FileWriteLine($file, ";[Installer Label 1]")
    FileWriteLine($file, ";path = someprogram.exe")
    FileWriteLine($file, ";[Installer Label 2]")
    FileWriteLine($file, ";path = .\path\someprogram.exe")
    FileWriteLine($file, ";[Installer Label 3]")
    FileWriteLine($file, ";path = D:\path\someprogram.exe")
    FileWriteLine($file, ";dir = D:\path")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Start entries here:")
    FileClose($file)
EndFunc

Func _Close()
    Exit
EndFunc

Sample ini file:

;INI file for Master Installer
;
;INI file format is:
;[SECTION]
;KEY = VALUE
;
;Section name is label for installation script.
;Key(s) are: Path
;
;Sample:
;[Installer Label 1]
;path = somepathram.exe
;[Installer Label 2]
;path = .\path\somepathram.exe
;[Installer Label 3]
;path = D:\path\somepathram.exe
;
;Start entries here:
[Configure LAN Settings]
path = Configure_LAN_Settings.exe
[Windows Patch]
path = Install_Windows_Patch.exe
[7zip 6.45]
path = Install_7zip_4-65.exe
[Configure 7zip 6.45]
path = Configure_7zip_4-65.exe
[Adobe Acrobat 8.10]
path = Install_Adobe_Reader_8-10.exe
[Copy Office 2000]
path = Copy_MS_Office_2000.exe
[Microsoft Office 2000]
path = Install_MS_Office_2000.exe
[Microsoft Office 2003]
path = Install_MS_Office_2003.exe

This is a second script that I sometimes use when the installation involved is the same across multiple machines. It skips the selection process and just sequentially executes the items in the ini file.

#include <Misc.au3>
_Singleton("Automated Launcher Script")
Opt("MustDeclareVars", 1)
HotKeySet("^!x", "_Close");Exit on Ctrl+Alt+X

Global $ininame = "_process_runner.ini"
Global $section = "Processes"

If $CmdLine[0] == 1 Then
    $ininame = $CmdLine[1]
EndIf

If Not FileExists($ininame) Then
    MsgBox(0x2030, "Error", "No """ & $ininame & """! Writing empty .ini file.")
    _CreateINI()
    Exit
EndIf
Global $list = IniReadSection($ininame, $section)
If @error == 1 Then
    MsgBox(0x2030, "Error", "Read fail for " & $ininame & "! File empty or invalid.")
    Exit
EndIf

Global $pID
For $i = 1 To $list[0][0]
    $pID = Run($list[$i][1])
    If @error <> 0 Then
        MsgBox(0x2030, "Error", "Failed to run " & $list[$i][1] & "!")
    EndIf
    ProcessWaitClose($pID)
Next

Func _CreateINI()
    Local $file = FileOpen($ininame, 2)
    FileWriteLine($file, ";INI file for Process Runner")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Key-Value pair format is: KEY = VALUE")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Note: Key can be any value.")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Sample:")
    FileWriteLine($file, ";[Processes]")
    FileWriteLine($file, ";sometext1 = someprogram.exe")
    FileWriteLine($file, ";sometext2 = .\path\someprogram.exe")
    FileWriteLine($file, ";sometext3 = D:\path\someprogram.exe")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Start entries here:")
    FileWriteLine($file, "[Processes]")
    FileClose($file)
EndFunc

Func _Close()
    Exit
EndFunc

This is the script I use to install Acrobat Reader.

#include <Misc.au3>
_Singleton("AutoIt Automated Script")
Opt("MustDeclareVars", 1)
HotKeySet("{PAUSE}", "_Close")
Func _Close()
    Exit
EndFunc
Func _ControlClick($title, $text, $controlID)
    WinWait($title, $text)
    WinActivate($title, $text)
    Sleep(200)
    ControlClick($title, $text, $controlID)
EndFunc

Global $ininame = "_install_adobe_reader_8-10.ini"
Global $section = "Options"
If Not FileExists($ininame) Then
    IniWrite($ininame, $section, "Path", ".\Adobe Reader 8.10\AdbeRdr810_en_US.exe")
    Exit
EndIf

Global $exec = IniRead($ininame, $section, "Path", ".\Adobe Reader 8.10\AdbeRdr810_en_US.exe")

Run($exec)
If Not @error Then
    _ControlClick("Adobe Reader 8.1.0 - Setup", "Change &Destination Folder", "[TEXT:&Next >]")
    _ControlClick("Adobe Reader 8.1.0 - Setup", "Click Install to begin the installation.", "[TEXT:&Install]")
    _ControlClick("Adobe Reader 8.1.0 - Setup", "Setup has successfully installed Adobe Reader 8.1.0.", "[TEXT:&Finish]")
    WinWaitClose("Adobe Reader 8.1.0 - Setup", "Setup has successfully installed Adobe Reader 8.1.0.")
EndIf

I invested my time creating some utility scripts to aid the creation and use of my installation scripts. It paid off by saving me some hassle in the process. By far the most useful but seldom used script I have in my collection is the one that logs information during the installation process. Although it is a little limited in some aspect, it saves me the trouble of having to look up window/control information when I click stuff. I have no intention of sharing it though since it's not allowed.

Posted

This is my "launcher" script. It allows you to generate a list from an ini file and select which item you want run. The only limitation it <SNIP>

</quote>

Looks good and so simple. I've been looking for a way to create a "list" with "check" boxes for a while but it was all too complicated. YEP I'm a GUI DUNCE :idea:

THANKS!

<quote>

I invested my time creating some utility scripts to aid the creation and use of my installation scripts. It paid off by saving me some hassle in the process. By far the most useful but seldom used script I have in my collection is the one that logs information during the installation process. Although it is a little limited in some aspect, it saves me the trouble of having to look up window/control information when I click stuff. I have no intention of sharing it though since it's not allowed.

Yeah...sigh... I get by with "AutoitMacroGenerator" then edit the results. Normally I have to install/uninstall/reinstall 2 or 3 times before I get it right... grrr

Thanks for the script above I'll be able to add a menu to a few things I haven't been able to!!

Have a great day!

Posted

Well, it takes me 2 to 4 installs to get a workable script. Once for recording, then a couple times for verification. Add a few more if there are a few cases that need to be handled, like when I made a script to install downloaded Windows patches on computers. (I had to handle it so that the script doesn't halt when a patch has already been previously applied, or if the path is for the wrong version of Windows.)

Posted

Well, it takes me 2 to 4 installs to get a workable script. Once for recording, then a couple times for verification. Add a few more if there are a few cases that need to be handled, like when I made a script to install downloaded Windows patches on computers. (I had to handle it so that the script doesn't halt when a patch has already been previously applied, or if the path is for the wrong version of Windows.)

sigh..... usually it's 3-4 times to get a workable script.... before testing... sigh (well maybe less for simple installs) r well :idea:

I started on a patch loader but then found "autopatcher" http://www.autopatcher.com I use it all the time to update computers. I know it's cheating (they do all the checking like "what is already installed") but it saves me a huge amount of time. Well worth a look! I've now seperated it so the different types of windows (xp, vista, Win 7, 32/64 bit) have seperate directories for patches and I have a single AutoIT script that decides which one to run when I'm upgrading a computer.

Hope you have a great day!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...