Jump to content

Need help with Select Case usage... or perhaps another issue?


sfunk1x
 Share

Recommended Posts

Hey all -

I'm trying to write an automated installation script for an app that I want to automate testing of. I'm running into an issue though - the app requires .NET 1.1 framework. Ok, I added the code to control automated installation of this, but my problem is this:

Sometimes the machines have .NET 1.1 framework. Some don't. I added some lines of code to try to differentiate between machines that have it vs those that don't. Installshield will recognize whether or not it exists and send the user down a seperate pathway for the .NET installation. My issue appears to be getting the script to recognize that the .NET install has occured. This is the code snippet I'm dealing with:

--------------------------

Select

Case WinExists ("InstallShield Wizard", "Configuring Microsoft® .NET Framework")

WinWaitActive ("Microsoft .NET Framework 1.1 Setup")

ControlClick ("Microsoft .NET Framework 1.1 Setup", "I &agree", "Button3", "left")

ControlClick ("Microsoft .NET Framework 1.1 Setup", "&Install", "Button4", "left")

WinWaitActive ("Microsoft .NET Framework 1.1 Setup", "Installation of Microsoft .NET Framework 1.1 is complete.")

ControlClick ("Microsoft .NET Framework 1.1 Setup", "OK", "Button1", "left")

Case WinExists ("********* - Setup")

WinWait("********* - Setup")

WinActivate("********* - Setup")

Sleep(3000)

ControlClick("********* - Setup", "&Next >", "Button1", "left")

ControlClick("********* - Setup", "I &do not accept the terms in the license agreement", "Button3", "left")

ControlClick("********* - Setup", "I &do not accept the terms in the license agreement", "Button5", "left")

ControlClick("********* - Setup", "&Typical", "Button6", "left")

WinWait("********* - Setup")

ControlClick("********* - Setup", "&Install", "Button1", "left")

EndSelect

-------------------------

I think some of the issue is because the first line of code where you see "Configuring Microsoft® .NET Framework" because that exact phrase does not appear immedaitely, it will appear after a few seconds on a slower machine because Installshield is determining the dependencies of the app - namely whether or not .NET is installed. But if I change it back to normal, would it not be too close to what it would be originally, therefore pushing it off into the portion of the script that installs the app, negating it's ability to go throught he .NET installation?

This probably sounds very confusing, but if anyone can help me I can probably un-confuse you ;)

Thanx in advance!

Link to comment
Share on other sites

No, actually it doesn't. The text in the middle is just text for that particular window, and doesn't represent the button it's actually clicking. I may actually not even need it there, but it executes properly anyway.

Thanks for lookin' out for me ;)

Link to comment
Share on other sites

No, actually it doesn't. The text in the middle is just text for that particular window, and doesn't represent the button it's actually clicking. I may actually not even need it there, but it executes properly anyway.

Thanks for lookin' out for me ;)

no problem. ok back to the issue. sorry i was a little confused by your first explanation, but do want to help. what is the problem behavior your script is actually exhibiting? is it not recognizing a window? is it not continuing when it should?
Link to comment
Share on other sites

no problem. ok back to the issue. sorry i was a little confused by your first explanation, but do want to help. what is the problem behavior your script is actually exhibiting? is it not recognizing a window? is it not continuing when it should?

Not continuing when it should, basically. It is getting confused I think because I (believe) am not using the Select/Case sequence properly.

Basically, I'd like to script to recognize that this particular path is being taken because .NET doesn't exist on the system.

Another method my attention was brought to would be to check the file system to see if .NET exists, which would be another excellent way to do it, but I am unsure of how to bypass certain code and move onto other bits... for example:

If FileExists("Blahblah.NETFolder") then ????

Else <run through .NET installation>

How would I get that THEN statement to run through the app installation code later on in the script, and bypass all the .NET installation code?

Let me know if I'm being unclear. Sounds kind of loopy to me, but maybe you can understand my gibberish ;)

Link to comment
Share on other sites

One way is to code if .Net doesn't exist, and then install everything else regardless

If Not FileExists("dotNetFile.txt") Then

;Commands to Install .Net

EndIf

;Commands to install program on all computers

Also, WinGetText works nicely, that way you don't have to assume that .Net is installed or not (just do a StringInStr comparison)

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

One way is to code if .Net doesn't exist, and then install everything else regardless

You can check for the existence of the folder: C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705 or something like that: "C:\" & @windowsdir & "\Microsoft.NET\Framework\v" to test if .net is installed. Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

OK, so I implemented the If NOT FileExists/EndIf statement, but now it seems as if it starts executing the If NOT statement, and as soon as it launches the .NET installer, it jumps out of the If/EndIf statement and starts executing the other code that installs the app.

Am I missing something?

--------------

If NOT FileExists("C:\" & @WindowsDir & "\Microsoft.NET\Framework\v1.1.4322") Then

Run("T:\Setup\1033dotnetfx.exe")

WinWait("Microsoft .NET Framework 1.1 Setup")

WinActivate("Microsoft .NET Framework 1.1 Setup")

ControlClick("Microsoft .NET Framework 1.1 Setup", "&Yes", "Button1", "left")

WinWait("Microsoft .NET Framework 1.1 Setup", "")

ControlClick("Microsoft .NET Framework 1.1 Setup", "I &agree", "Button3", "left")

ControlClick("Microsoft .NET Framework 1.1 Setup", "&Install", "Button4", "left")

WinWait("Microsoft .NET Framework 1.1 Setup", "")

ControlClick("Microsoft .NET Framework 1.1 Setup", "OK", "Button1", "left")

EndIf

; Installation Start

Run("T:\setup.exe")

WinWait("*******")

WinActivate("*******")

Sleep(1500)

ControlClick("*******", "&Next >", "Button1", "left")

ControlClick("*******", "I &do not accept the terms in the license agreement", "Button3", "left")

ControlClick("*******", "I &do not accept the terms in the license agreement", "Button5", "left")

ControlClick("*******", "&Typical", "Button6", "left")

WinWait("*******")

ControlClick("*******", "&Install", "Button1", "left")

Edited by sfunk1x
Link to comment
Share on other sites

Thanks for pointing that out. Now it runs the check for .NET properly (was launching the installer regardless).. but, I'm still having the problem of it executing the code outside the If/EndIf statement before the .NET installer is finished doing it's thing.

I tried ProcessWaitClose, but the problem then is that it immediately jumps through all that other code and waits until the process finishes, and of course it never finishes because it requires user input that I placed code above the ProcessWaitClose statement for... I also tried placing ProcessWaitClose inside the If statement, and just before the rest of the App install code, but it doesn't seem to make a difference.

Edited by sfunk1x
Link to comment
Share on other sites

Thanks for pointing that out. Now it runs the check for .NET properly (was launching the installer regardless).. but, I'm still having the problem of it executing the code outside the If/EndIf statement before the .NET installer is finished doing it's thing.

I tried ProcessWaitClose, but the problem then is that it immediately jumps through all that other code and waits until the process finishes, and of course it never finishes because it requires user input that I placed code above the ProcessWaitClose statement for... I also tried placing ProcessWaitClose inside the If statement, and just before the rest of the App install code, but it doesn't seem to make a difference.

there is not enough code here to help you with that

8)

NEWHeader1.png

Link to comment
Share on other sites

Here is the script in it's entirety. The portion with the If NOT statement installs the .NET framework. All the code after the EndIf deals with automating the install and web registration of the application.

TIA!

-----------------------------------------------

; Debug line, remove after finalization

Opt("Trayicondebug",1)

; Script Start

;-------------

;Drive Mapping in preparation of install - This will have the effect of launching autorun for *** as well.

drivemapadd("T:", "\\bluebird\E", 8, "sean", "sean")

; .NET 1.1 installation check begins

If NOT FileExists( @WindowsDir & "\Microsoft.NET\Framework\v1.1.4322") Then

Run("T:\Setup\1033dotnetfx.exe /q")

ControlClick("Microsoft .NET Framework 1.1 Setup", "I &agree", "Button3", "left")

ControlClick("Microsoft .NET Framework 1.1 Setup", "&Install", "Button4", "left")

WinWait("Microsoft .NET Framework 1.1 Setup", "")

ControlClick("Microsoft .NET Framework 1.1 Setup", "OK", "Button1", "left")

EndIf

; Installation Start

Run("T:\setup.exe")

WinWait("********* - Setup")

WinActivate("********* - Setup")

Sleep(1500)

ControlClick("********* - Setup", "&Next >", "Button1", "left")

ControlClick("********* - Setup", "I &do not accept the terms in the license agreement", "Button3", "left")

ControlClick("********* - Setup", "I &do not accept the terms in the license agreement", "Button5", "left")

ControlClick("********* - Setup", "&Typical", "Button6", "left")

WinWait("********* - Setup")

ControlClick("********* - Setup", "&Install", "Button1", "left")

; The installation has been started and the user will be prompted to

; register the software. This script will register as a person outside

; the US.

WinWait("********* Registration")

Sleep(3000)

ControlClick("********* Registration", "13 or Older", "Button2", "left")

WinWait("********* Registration")

Sleep(3000)

ControlClick("********* Registration", "Quit", "Button1", "left")

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

WinWait("********* Registration","")

If Not WinActive("********* Registration","") Then WinActivate("********* Registration","")

;WinWaitActive("********* Registration","")

MouseMove(48,57)

MouseDown("left")

MouseUp("left")

Sleep(1000)

MouseMove(626,475)

MouseDown("left")

MouseUp("left")

; The final installation screen will now be shown and handled by the script.

WinWait("*********® - Microsoft Internet Explorer","")

WinClose("*********® - Microsoft Internet Explorer","")

WinWait("********* - Setup","")

If Not WinActive("********* - Setup","") Then

WinActivate("********* - Setup","")

EndIf

Sleep(1500)

ControlClick("********* - Setup", "&Finish", "Button1", "left")

; Removal of script mapped drive(s)

DriveMapDel("E:")

Edited by sfunk1x
Link to comment
Share on other sites

Ugh, I was dumb. A good nights rest and a milkshake helped me that my wait statements were both commented out and didn't exist properly. Once those were taken car eof, the issues were resolved. Fully functional script with a check for .NET installation now! So, the framework is now complete thanks to several people who helped me debug, and I'm onto broader and better projects with AutoIt :-)

Thanks again!

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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