RhoSysAdmin
asked on
AutoIT script gets stuck during simple unattended install
I have the script below trying to install a simple windows app. It gets stuck on the "Customer Information" window where I try to enter text in the fields. I've tried several combinations but cannot seem to get it past this window. This is my first AutoIT script, so I'm hopeful it's something simple I'm missing.
#RequireAdmin
; Run SAS System Viewer 9.1 installer
Run("setup.exe")
; Initial setup screen
WinWaitActive("InstallShie ld Wizard", "Welcome to the SAS System Viewer")
Send("!n")
; Customer Information
WinWaitActive("Installshie ld Wizard", "Customer Information")
Send("RHO{TAB}")
Send("Rho, Inc.!n")
; Select Language
WinWaitActive("Installshie ld Wizard", "Select Language")
Send("!n")
; Choose Destination Folder
WinWaitActive("Installshie ld Wizard", "Choose Destination Folder")
Send("!n")
; SAS Shared Files
WinWaitActive("Installshie ld Wizard", "SAS Shared Files")
Send("!n")
; Select Program Folder
WinWaitActive("Installshie ld Wizard", "Select Program Folder")
Send("!n")
; Start Copying Files
WinWaitActive("Installshie ld Wizard", "Start Copying Files")
Send("!n")
; Completed installation screen
WinWaitActive("Installshie ld Wizard", "SAS System Viewer 9.1 Setup Complete")
Send("{ENTER}")
#RequireAdmin
; Run SAS System Viewer 9.1 installer
Run("setup.exe")
; Initial setup screen
WinWaitActive("InstallShie
Send("!n")
; Customer Information
WinWaitActive("Installshie
Send("RHO{TAB}")
Send("Rho, Inc.!n")
; Select Language
WinWaitActive("Installshie
Send("!n")
; Choose Destination Folder
WinWaitActive("Installshie
Send("!n")
; SAS Shared Files
WinWaitActive("Installshie
Send("!n")
; Select Program Folder
WinWaitActive("Installshie
Send("!n")
; Start Copying Files
WinWaitActive("Installshie
Send("!n")
; Completed installation screen
WinWaitActive("Installshie
Send("{ENTER}")
ASKER
I did use the Windows Info Tool to get the text and window names correct. The first field where I'm trying to enter the text is highlighted, but my text is not entered.
Have you tried not entering any text information and just sending the !n to skip to the next screen? (not a final solution, just trying to find out where it is stuck here)
From the sounds of it, it is not recognizing that you are on the correct screen. If you take the section for that screen out can you manually do that page and get to the next part?
From the sounds of it, it is not recognizing that you are on the correct screen. If you take the section for that screen out can you manually do that page and get to the next part?
A better way to enter text in items like that (known as Edit controls) is to use the function ControlSetText() instead of Send(). First use the Window Info Tool to get the class and instance of the control, which is usually just Edit1, Edit2, etc. For example, the "Customer Information" section of your code could look like this:
; Customer Information
WinWaitActive("Installshie ld Wizard", "Customer Information")
ControlSetText("Installshi eld Wizard", "Customer Information", "Edit1", "RHO")
ControlSetText("Installshi eld Wizard", "Customer Information", "Edit2", "Rho, Inc.")
Send("!n")
I have had many a script that failed at those types of windows, until I started using ControlSetText().
You may also want to use ControlClick to click the "Next" button, instead of sending the keyboard shortcut keys for it. It's a more sure-fire way of ensuring that your commands are getting to the program windows.
; Customer Information
WinWaitActive("Installshie
ControlSetText("Installshi
ControlSetText("Installshi
Send("!n")
I have had many a script that failed at those types of windows, until I started using ControlSetText().
You may also want to use ControlClick to click the "Next" button, instead of sending the keyboard shortcut keys for it. It's a more sure-fire way of ensuring that your commands are getting to the program windows.
ASKER
I'm still working on this, but you've brought up another question to mind. I want to run this compiled exe as an unattended install pushed out via SCCM. I saw another forum where they recomended not using WinWaitActive at all. If my goal is 100% unattended, how much more do I need to change in my au3 script?
Hmm, without using a WinWait/Activate function I don't know how AutoIT would know when to send the appropriate commands. I would think you would at least have to use WinWait, but yes depending on the program being installed you don't always need window-activating function. Theoretically you could get away with just using WinWait, but then you would definitely have to use the ControlSetText and ControlClick functions (as opposed to using Send).
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Another idea - in the rare instance I do need to use the Send function and send ALT keys with it, I always use {ALTDOWN} and {ALTUP}, it seems to work more often. Sending "ALT+n" would look like this:
Send("{ALTDOWN}n{ALTUP}")
Send("{ALTDOWN}n{ALTUP}")
ASKER
i know it should not be this hard. I'm taking the value for my "Next" button right from the AutoIT v3 Window Info tool. I've tried every variation of how to specify which button to click (w/ ControlClick) and now I cannot get through any of the windows.
It does fill in the next in the appropriate fields on the one window, but I'm unable to advance through any of them.
It does fill in the next in the appropriate fields on the one window, but I'm unable to advance through any of them.
I downloaded SAS Sytem Viewer 9.1.3 from SAS, but it appears to be a slightly different version so that's a bust.
The value entered for the ControlID in the ControlCLick function should just be a combination of the Class and Instance of the control, or the ClassnameNN as shown in the screen shot below. A good way to test these silent install scripts is with Msgbox. Try the code below and see how far you're getting, but of course replace the control IDs with the actual ones from your window info tool:
The value entered for the ControlID in the ControlCLick function should just be a combination of the Class and Instance of the control, or the ClassnameNN as shown in the screen shot below. A good way to test these silent install scripts is with Msgbox. Try the code below and see how far you're getting, but of course replace the control IDs with the actual ones from your window info tool:
; Customer Information
Msgbox(0, "", "About to start waiting for window")
WinWait("Installshield Wizard", "Customer Information")
Msgbox(0, "", "Window was found/waited for, will now try activating it")
If WinActivate("Installshield Wizard", "Customer Information")=0 Then
Msgbox(0, "", "Failed to activate window!")
Else
Msgbox(0, "", "Window was activated, will now try to enter 1st text")
EndIf
If ControlSetText("Installshield Wizard", "Customer Information", "Edit1", "RHO")=0 Then
Msgbox(0, "", "Failed to enter 1st text!")
Else
Msgbox(0, "", "1st text was entered, will now try to enter 2nd text")
EndIf
If ControlSetText("Installshield Wizard", "Customer Information", "Edit2", "Rho, Inc.")=0 Then
Msgbox(0, "", "Failed to enter 2nd text!")
Else
Msgbox(0, "", "2nd text was entered, will now try to click Next button")
EndIf
If ControlClick("Installshield Wizard", "Customer Information", "Button1")=0 Then
Msgbox(0, "", "Failed to click Next button!")
Else
Msgbox(0, "", "Next was clicked")
EndIf
ASKER
I wonder if I'm compiling it wrong. I only see the first pop-up. I see an AutoIT icon in the system tray that tells me the script is paused. I don't see to be able to get past the first dialog box.
It shouldn't pause execution unless you actually click (left or right) on the system tray icon.
If possible, can you run the SAS installation on a computer that has AutoIT installed? That way, within SciTE you can just press F5 at any time to run the script without having to compile it to an EXE.
It's odd that it would fail at the WinWait function, are you absolutely sure that the "text" is correct? Obviously the "title" is right since it gets past the initial welcome window. WinWait is one of the few functions that will sit and wait forever for a window, so something is going on with its ability to recognize that window.
If possible, can you run the SAS installation on a computer that has AutoIT installed? That way, within SciTE you can just press F5 at any time to run the script without having to compile it to an EXE.
It's odd that it would fail at the WinWait function, are you absolutely sure that the "text" is correct? Obviously the "title" is right since it gets past the initial welcome window. WinWait is one of the few functions that will sit and wait forever for a window, so something is going on with its ability to recognize that window.
ASKER
It's behaving differently on different computers, even though they're both Windows 7 and I'm logged in as local admin on both. Clearly, I'm not matching it up right. I'm out of time, so will try again on Monday.
Thanks so much for the help!
Thanks so much for the help!
ASKER
I finally got this working w/ TheGorby's recommendation. I had left out the visible text on the WinWait function.
; Customer Information
WinWait("Installshield Wizard", "Customer Information")
WinActivate("Installshield Wizard", "Customer Information")
ControlSetText("Installshi eld Wizard", "Customer Information", "Edit1", "RHO")
ControlSetText("Installshi eld Wizard", "Customer Information", "Edit2", "Rho, Inc.")
ControlClick("Installshiel d Wizard", "Customer Information", "Button1")
Now I have a new issue. I can install with this script and I can push this out via SCCM so long as I enable "Allow user to interact...". The thing is I would like to include this in an OSD task sequence in SCCM. OSD will not allow the program b/c I have the "interact" feature enabled. Is there a way to tweak SCCM or the AutoIT script so this can run 100% unattended?
I can post a new question if necessary.
Thanks!!
; Customer Information
WinWait("Installshield Wizard", "Customer Information")
WinActivate("Installshield
ControlSetText("Installshi
ControlSetText("Installshi
ControlClick("Installshiel
Now I have a new issue. I can install with this script and I can push this out via SCCM so long as I enable "Allow user to interact...". The thing is I would like to include this in an OSD task sequence in SCCM. OSD will not allow the program b/c I have the "interact" feature enabled. Is there a way to tweak SCCM or the AutoIT script so this can run 100% unattended?
I can post a new question if necessary.
Thanks!!
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
That is just awesome. That solved my issue from beginning to end. I have to work on my searching skills b/c I use myitforum all the time and didn't see that article.
Thanks so much!!
Thanks so much!!
ASKER
One expert solved two different issues with the same problem. I really appreciate all the quick responses. I never would have resolved this without TheGorby's help or this web site.
http://www.autoitscript.com/autoit3/docs/intro/au3spy.htm
There seems to be two possibilities here:
1. the conditions are not being met, and therefore it is waiting forever
2. the keystrokes which are sent when the conditions are met do not cause the installer to advance properly
Is the focus as you would expect when the installer "hangs" on this screen?