• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1932
  • Last Modified:

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("InstallShield Wizard", "Welcome to the SAS System Viewer")
Send("!n")

; Customer Information
WinWaitActive("Installshield Wizard", "Customer Information")
Send("RHO{TAB}")
Send("Rho, Inc.!n")

; Select Language
WinWaitActive("Installshield Wizard", "Select Language")
Send("!n")

; Choose Destination Folder
WinWaitActive("Installshield Wizard", "Choose Destination Folder")
Send("!n")

; SAS Shared Files
WinWaitActive("Installshield Wizard", "SAS Shared Files")
Send("!n")

; Select Program Folder
WinWaitActive("Installshield Wizard", "Select Program Folder")
Send("!n")

; Start Copying Files
WinWaitActive("Installshield Wizard", "Start Copying Files")
Send("!n")

; Completed installation screen
WinWaitActive("Installshield Wizard", "SAS System Viewer 9.1 Setup Complete")
Send("{ENTER}")
0
RhoSysAdmin
Asked:
RhoSysAdmin
  • 8
  • 7
  • 2
2 Solutions
 
jmcmunnCommented:
Have you used the Window Info Tool to verify that everything is spelled correctly and matches exactly what is is during the install?

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?
0
 
RhoSysAdminAuthor Commented:
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.  
0
 
jmcmunnCommented:
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?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
TheGorbyCommented:
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("Installshield Wizard", "Customer Information")
ControlSetText("Installshield Wizard", "Customer Information", "Edit1", "RHO")
ControlSetText("Installshield 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.
0
 
RhoSysAdminAuthor Commented:
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?

0
 
TheGorbyCommented:
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).
0
 
TheGorbyCommented:
Ideally each "section" of your code would look something like this:

; Customer Information
WinWait("Installshield Wizard", "Customer Information")
WinActivate("Installshield Wizard", "Customer Information")
ControlSetText("Installshield Wizard", "Customer Information", "Edit1", "RHO")
ControlSetText("Installshield Wizard", "Customer Information", "Edit2", "Rho, Inc.")
ControlClick("Installshield Wizard", "Customer Information", "Button1")

"Button1" would be the class and instance of the Next button on that window. There was just one time that I had code that didn't work with WinWaitActivate but did work with WinWait and WinActivate, so I've used those 2 in combination ever since.
0
 
TheGorbyCommented:
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}")
0
 
RhoSysAdminAuthor Commented:
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.

0
 
TheGorbyCommented:
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. ScreenshotA 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

Open in new window

0
 
RhoSysAdminAuthor Commented:
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.
0
 
TheGorbyCommented:
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.
0
 
RhoSysAdminAuthor Commented:
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!

0
 
RhoSysAdminAuthor Commented:
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("Installshield Wizard", "Customer Information", "Edit1", "RHO")
ControlSetText("Installshield Wizard", "Customer Information", "Edit2", "Rho, Inc.")
ControlClick("Installshield 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!!


0
 
TheGorbyCommented:
I unfortunately have no experience with SCCM, but the link below looks promising:

http://www.myitforum.com/absolutenm/templates/Articles.aspx?articleid=22289&zoneid=89

To use that method you'll need to install the MDT2010, available here:

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=25175

If this doesn't work, then yes I'd suggest opening a new question.
0
 
RhoSysAdminAuthor Commented:
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!!

0
 
RhoSysAdminAuthor Commented:
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.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 8
  • 7
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now