Sign in to follow this  
Followers 0
Petzl

New user help....

15 posts in this topic

I am trying to get a program to uninstall automatically for me. I have 2 issues:

1 - It sometimes runs and sometimes does not...the runwait command works fine. I am then trying to send a command to change from repair to remove the program with the Send ("!R"). The Send ("!N") is to click Next and the Send ("{ENTER}") is to select OK to commence the uninstall. It seems to stall at the Send ("!R") stage. If I cancel the program and then click on the autoIT program again it seems to run fine. Is there some sort of clearing process I need to run?

2 - It leaves the autoit exe running in the system tray and I want to kill it once it all finishes.

WinMinimizeAll()

RunWait('"C:\Program Files\Common Files\InstallShield\Driver\1150\Intel 32\IDriver.exe" /M{FEF12058-6014-492E-9116-3BB168549C9C}')

WinWaitActive("Program Setup")

Sleep(2000)

Send ("!R")

Send ("!N")

Send ("{ENTER}")

WinWaitActive("Program Setup")

Send ("{ENTER}")

Func ExitScript()

Exit

EndFunc

Thanks very much for the help!

Share this post


Link to post
Share on other sites



I am trying to get a program to uninstall automatically for me. I have 2 issues:

1 - It sometimes runs and sometimes does not...the runwait command works fine. I am then trying to send a command to change from repair to remove the program with the Send ("!R"). The Send ("!N") is to click Next and the Send ("{ENTER}") is to select OK to commence the uninstall. It seems to stall at the Send ("!R") stage. If I cancel the program and then click on the autoIT program again it seems to run fine. Is there some sort of clearing process I need to run?

2 - It leaves the autoit exe running in the system tray and I want to kill it once it all finishes.

WinMinimizeAll()

RunWait('"C:\Program Files\Common Files\InstallShield\Driver\1150\Intel 32\IDriver.exe" /M{FEF12058-6014-492E-9116-3BB168549C9C}')

WinWaitActive("Program Setup")

Sleep(2000)

Send ("!R")

Send ("!N")

Send ("{ENTER}")

WinWaitActive("Program Setup")

Send ("{ENTER}")

Func ExitScript()

Exit

EndFunc

Thanks very much for the help!

Some questions:

Why WinWaitActive() for the same window again? Does it go away and come back, or open a second window with the same title? Since you check it right after sending ENTER the change may not have happened yet. Maybe a Sleep(1000) before the second WinWaitActive().

The ExitScript() function is never called, so why is it declared here?

(And welcome to AutoIt.)

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Some questions:

Why WinWaitActive() for the same window again? Does it go away and come back, or open a second window with the same title? Since you check it right after sending ENTER the change may not have happened yet. Maybe a Sleep(1000) before the second WinWaitActive().

The ExitScript() function is never called, so why is it declared here?

(And welcome to AutoIt.)

:P

Hi PsaltyDS,

Thanks for the reply. My ignorance is clear to see;-)

Yes it does go away and open a final window requiring you to close that window. Unfortunately the window name is the same as well. ExitScript was my attempt at closing the script process sitting in the system tray.

The initial failure to run the Send ("!R") won't be helped though by adding a Sleep(1000) before the second WinWaitActive() will it? If it runs it goes all the way through. Trouble is it seems to be getting stuck after the first WinWaitActive() and prior to the Send ("!R").

Thanks,

Petzl!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi PsaltyDS,

Thanks for the reply. My ignorance is clear to see;-)

Yes it does go away and open a final window requiring you to close that window. Unfortunately the window name is the same as well. ExitScript was my attempt at closing the script process sitting in the system tray.

The initial failure to run the Send ("!R") won't be helped though by adding a Sleep(1000) before the second WinWaitActive() will it? If it runs it goes all the way through. Trouble is it seems to be getting stuck after the first WinWaitActive() and prior to the Send ("!R").

Thanks,

Petzl!

I'm not sure you know that's where it really fails, because there is no error checking/handling in your script. Look at this version:
Global $sProgDir = "C:\Program Files\Common Files\InstallShield\Driver\1150\Intel 32"
Global $sProgExe = "IDriver.exe"
Global $sProgPath = $sProgDir & "\" & $sProgExe
Global $sRunLine = $sProgPath & ' /M{FEF12058-6014-492E-9116-3BB168549C9C}'
Global $sWinTitle = "Program Setup"

WinMinimizeAll()

Run($sRunLine, $sProgDir)

; Wait max 10sec for first window
If Not WinWait($sWinTitle, "", 10) Then
    MsgBox(16, "Error", "First window did not occur before timeout:  " & $sWinTitle)
    Exit
EndIf

WinActivate($sWinTitle, "")
ControlSend($sWinTitle, "", "", "!R")
ControlSend($sWinTitle, "", "", "!N")
ControlSend($sWinTitle, "", "", "{ENTER}")

; Waits max 10sec for old window to close
If Not WinWaitClose($sWinTitle, "", 10) Then
    MsgBox(16, "Error", "First window did not close before timeout:  " & $sWinTitle)
    Exit
EndIf

; Wait max 10sec for second window
If Not WinWait($sWinTitle, "", 10) Then
    MsgBox(16, "Error", "Second window did not occur before timeout:  " & $sWinTitle)
    Exit
EndIf

WinActivate($sWinTitle, "")
ControlSend($sWinTitle, "", "", "{ENTER}")

The changes are less complicated than they look:

1. Put all the literal strings in variables. No big deal here, but a good practice to get into because it makes debugging/changing the script easier for when your scripts get longer and more complicated. For example, if you had to change the window title string used, it can be changed in only one place at the top, and the $sWinTitle variable makes the change everywhere else.

2. Run() vice RunWait(). RunWait() will "block" (pause) the script until the process finishes. I'm not sure you want to do that here, since you want to handle a dialog from that process.

3. Timeouts plus error handling for the wait functions. Allows you to know if it misses something, rather than just hanging forever. The 10 second value was a guess on my part, adjust as required to about twice the time it normally takes.

4. ControlSend() vice Send(). Always more reliable because it targets the specific window (and control if provided, but that's optional and not used here). The target window doesn't even need to be active to get the key strokes.

5. Using ControlSend() makes it unnecessary, but WinActivate() is still there to make sure you get to watch what's happening.

Hope that helps.

:P

Edit: Replaced missing "Then" keyword.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks for all your help PsaltyDS,

I have called the script 'Test'. When running it I am getting the following error.....

Line 0 (C:\Documents and Settings\Mark\Desktop\Test.exe

If Not WinWait($sWinTitle,"",10)

Error "If" statements must have a "Then" keyword

Thanks,

Petzl

Share this post


Link to post
Share on other sites

Thanks for all your help PsaltyDS,

I have called the script 'Test'. When running it I am getting the following error.....

Line 0 (C:\Documents and Settings\Mark\Desktop\Test.exe

If Not WinWait($sWinTitle,"",10)

Error "If" statements must have a "Then" keyword

Thanks,

Petzl

Yeah, that should have been just like the other ones:
If Not WinWait($sWinTitle,"",10) Then

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Yeah, that should have been just like the other ones:

If Not WinWait($sWinTitle,"",10) Then

:D

Hi PsaltyDS,

This is great....I have had to make a few changes but I think it is close! It was giving the error messages which helped isolate the problems. I adjusted the first timeout to 15 seconds. It was getting the hanging on the "First window did not close before timeout: " section so it removed it from the equation and it works great each time. The only issue left is that it is not finalising the last window with the

WinActivate($sWinTitle, "") and ControlSend($sWinTitle, "", "", "{ENTER}") commands. Any thoughts?

Changed script now looks like this:

Global $sProgDir = "C:\Program Files\Common Files\InstallShield\Driver\1150\Intel 32"

Global $sProgExe = "IDriver.exe"

Global $sProgPath = $sProgDir & "\" & $sProgExe

Global $sRunLine = $sProgPath & ' /M{FEF12058-6014-492E-9116-3BB168549C9C}'

Global $sWinTitle = "ACT! Setup"

WinMinimizeAll()

Run($sRunLine, $sProgDir)

; Wait max 10sec for first window

If Not WinWait($sWinTitle, "", 15) Then

MsgBox(16, "Error", "First window did not occur before timeout: " & $sWinTitle)

Exit

EndIf

WinActivate($sWinTitle, "")

ControlSend($sWinTitle, "", "", "!R")

ControlSend($sWinTitle, "", "", "!N")

ControlSend($sWinTitle, "", "", "{ENTER}")

; Waits max 10sec for old window to close

;If Not WinWaitClose($sWinTitle, "", 10) Then

; MsgBox(16, "Error", "First window did not close before timeout: " & $sWinTitle)

; Exit

;EndIf

; Wait max 10sec for second window

If Not WinWait($sWinTitle, "", 10) Then

MsgBox(16, "Error", "Second window did not occur before timeout: " & $sWinTitle)

Exit

EndIf

WinActivate($sWinTitle, "")

ControlSend($sWinTitle, "", "", "{ENTER}")

Thanks so much for your help!

Petzl

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Hi PsaltyDS,

This is great....I have had to make a few changes but I think it is close! It was giving the error messages which helped isolate the problems. I adjusted the first timeout to 15 seconds. It was getting the hanging on the "First window did not close before timeout: " section so it removed it from the equation and it works great each time. The only issue left is that it is not finalising the last window with the

WinActivate($sWinTitle, "") and ControlSend($sWinTitle, "", "", "{ENTER}") commands. Any thoughts?

Changed script now looks like this:

CODE
Global $sProgDir = "C:\Program Files\Common Files\InstallShield\Driver\1150\Intel 32"

Global $sProgExe = "IDriver.exe"

Global $sProgPath = $sProgDir & "\" & $sProgExe

Global $sRunLine = $sProgPath & ' /M{FEF12058-6014-492E-9116-3BB168549C9C}'

Global $sWinTitle = "ACT! Setup"

WinMinimizeAll()

Run($sRunLine, $sProgDir)

; Wait max 10sec for first window

If Not WinWait($sWinTitle, "", 15) Then

MsgBox(16, "Error", "First window did not occur before timeout: " & $sWinTitle)

Exit

EndIf

WinActivate($sWinTitle, "")

ControlSend($sWinTitle, "", "", "!R")

ControlSend($sWinTitle, "", "", "!N")

ControlSend($sWinTitle, "", "", "{ENTER}")

; Waits max 10sec for old window to close

;If Not WinWaitClose($sWinTitle, "", 10) Then

; MsgBox(16, "Error", "First window did not close before timeout: " & $sWinTitle)

; Exit

;EndIf

; Wait max 10sec for second window

If Not WinWait($sWinTitle, "", 10) Then

MsgBox(16, "Error", "Second window did not occur before timeout: " & $sWinTitle)

Exit

EndIf

WinActivate($sWinTitle, "")

ControlSend($sWinTitle, "", "", "{ENTER}")

Thanks so much for your help!

Petzl

Probably just needs some help with the timing.

I missed why you commented out the test for the window closing? Why not just extend the timeout to the time required?

I am assuming that when you hit !R, !N, then {ENTER}, it will close that window and open a new one. If that doesn't happen instantaneously (and it doesn't even if it looks that way), then you need to wait for the first window to close and the new window to open before sending the final {ENTER}.

If you code that with no checks for the timing, AutoIt will send {ENTER} to the first window twice within a few milliseconds and be done before the first window has time to react and close.

If the first window doesn't close, it just changes text, then start using the second "Text" parameter in WinWait() to wait for the final window.

Something like:

WinActivate($sWinTitle, "")
ControlSend($sWinTitle, "", "", "!R")
ControlSend($sWinTitle, "", "", "!N")
ControlSend($sWinTitle, "", "", "{ENTER}")

If Not WinWait($sWinTitle, "Installation successfully completed", 10) Then
    MsgBox(16, "Error", "Success window did not occur before timeout:  " & $sWinTitle)
    Exit
EndIf

WinActivate($sWinTitle, "Installation successfully completed")
ControlSend($sWinTitle, "", "", "{ENTER}")

:D

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Hi PsaltyDS,

I commented out the the second section because it kept coming up in the middle of the uninstall with the error text.

The final window is unfortunately the same text as the first window so it might be getting confused? I changed the last section to a 90 timeout as per script below. The final window comes up and then the error "Second window did not occur before timeout: " pops up......so it clearly is not recognising that final window.

If Not WinWait($sWinTitle, "Installation successfully completed", 90) Then

MsgBox(16, "Error", "Second window did not occur before timeout: " & $sWinTitle)

Exit

EndIf

Thanks,

Petzl

Share this post


Link to post
Share on other sites

Hi PsaltyDS,

I commented out the the second section because it kept coming up in the middle of the uninstall with the error text.

The final window is unfortunately the same text as the first window so it might be getting confused? I changed the last section to a 90 timeout as per script below. The final window comes up and then the error "Second window did not occur before timeout: " pops up......so it clearly is not recognising that final window.

If Not WinWait($sWinTitle, "Installation successfully completed", 90) Then
    MsgBox(16, "Error", "Second window did not occur before timeout:  " & $sWinTitle)
    Exit
EndIf

Thanks,

Petzl

Now you're confusing me. If the last window has the same title, the same text, and the same ENTER button, then how do you know it's another window at all? How can you tell it's done?

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Now you're confusing me. If the last window has the same title, the same text, and the same ENTER button, then how do you know it's another window at all? How can you tell it's done?

:D

Lol...ok...it has the Same Window title at the top (ACT! Setup)...which is what I meant by same window. It says in the text that the uninsntall is complete and the button says 'Finish'.

Hope that makes more sense?

I have also noticed one other thing that might be causing our problem. Even though the small 'ACT! Setup' window dissapears, I have noticed that the Applications listed in the task manager has an application called 'ACT! Setup' so I am thinking that the ACT! Setup window is not something that can be relied on in finalising the script?

Petzl :o

Edited by Petzl

Share this post


Link to post
Share on other sites

Lol...ok...it has the Same Window title at the top (ACT! Setup)...which is what I meant by same window. It says in the text that the uninsntall is complete and the button says 'Finish'.

Hope that makes more sense?

I have also noticed one other thing that might be causing our problem. Even though the small 'ACT! Setup' window dissapears, I have noticed that the Applications listed in the task manager has an application called 'ACT! Setup' so I am thinking that the ACT! Setup window is not something that can be relied on in finalising the script?

Petzl :o

Why did you say "The final window is unfortunately the same text as the first window..."? Did you only mean the window title? I was specifically talking about the window TEXT not the title.

If the text in the window changes, then we are back to my last suggestion, the text parameter. Something like this:

If WinWait("ACT! Setup", "Uninstall is complete", 90) Then
     ControlSend("ACT! Setup", "Uninstall is complete", "", "{ENTER}")
Else
     MsgBox(16, "Error!", "Uninstall did not complete before timeout.")
EndIf

Note the title and text are case sensitive, so edit them to match exactly.

It's also about time you started using the AU3Info.exe tool to examine the GUI you are working with. Look at the visible window text, the control ID on the buttons you want to click, etc. That opens up additional options, like waiting for a button with the text "Finish" or "&Finish" to appear be enabled before continuing.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

It's also about time you started using the AU3Info.exe tool to examine the GUI you are working with. Look at the visible window text, the control ID on the buttons you want to click, etc. That opens up additional options, like waiting for a button with the text "Finish" or "&Finish" to appear be enabled before continuing.

:D

OK PsaltyDS....I looked at the tool and it opened up my eyes a little. I realised what you were saying about text vs titles! My script now works and is as follows:

Global $sProgDir = "C:\Program Files\Common Files\InstallShield\Driver\1150\Intel 32"

Global $sProgExe = "IDriver.exe"

Global $sProgPath = $sProgDir & "\" & $sProgExe

Global $sRunLine = $sProgPath & ' /M{FEF12058-6014-492E-9116-3BB168549C9C}'

Global $sWinTitle = "ACT! Setup"

WinMinimizeAll()

ProcessClose("Winword.exe")

ProcessClose("Outlook.exe")

ProcessClose("Excel.exe")

ProcessClose("IExplore.exe")

Sleep(5000)

Run($sRunLine, $sProgDir)

; Wait max 15 sec for first window

;If Not WinWait($sWinTitle, "Welcome", 15) Then

; MsgBox(16, "Error", "First window did not occur before timeout: " & $sWinTitle)

; Exit

;EndIf

;Send commands to commence installation

WinWaitActive($sWinTitle, "Welcome")

WinActivate($sWinTitle, "Welcome")

ControlSend($sWinTitle, "", "", "!R")

ControlSend($sWinTitle, "", "", "!N")

ControlSend("Confirm Uninstall", "", "", "{ENTER}")

;Send commands to close 'Finish' window

WinWaitActive($sWinTitle, "Uninstall Complete")

ControlSend($sWinTitle, "Uninstall Complete", "", "{ENTER}")

Works pretty well. I do have one more change to make though. I don't understand enough about the the global decs at the start and will have to learn more but once the script above is finished, I want to kick off the new install. The command is \\Server\ACTData\ACTINSTALL\ACTWG\setup.exe /s /f1"\\Server\ACTData\ACTINSTALL\ACTWG\SI\issconfig.iss" /f2"c:\installation_output.log".

How would I incorporate this into my script?

Once again, I appreciate your patience and apologies for the misunderstanding! :o

Petzl

Share this post


Link to post
Share on other sites

OK PsaltyDS....I looked at the tool and it opened up my eyes a little. I realised what you were saying about text vs titles! My script now works and is as follows:

CODE
Global $sProgDir = "C:\Program Files\Common Files\InstallShield\Driver\1150\Intel 32"

Global $sProgExe = "IDriver.exe"

Global $sProgPath = $sProgDir & "\" & $sProgExe

Global $sRunLine = $sProgPath & ' /M{FEF12058-6014-492E-9116-3BB168549C9C}'

Global $sWinTitle = "ACT! Setup"

WinMinimizeAll()

ProcessClose("Winword.exe")

ProcessClose("Outlook.exe")

ProcessClose("Excel.exe")

ProcessClose("IExplore.exe")

Sleep(5000)

Run($sRunLine, $sProgDir)

; Wait max 15 sec for first window

;If Not WinWait($sWinTitle, "Welcome", 15) Then

; MsgBox(16, "Error", "First window did not occur before timeout: " & $sWinTitle)

; Exit

;EndIf

;Send commands to commence installation

WinWaitActive($sWinTitle, "Welcome")

WinActivate($sWinTitle, "Welcome")

ControlSend($sWinTitle, "", "", "!R")

ControlSend($sWinTitle, "", "", "!N")

ControlSend("Confirm Uninstall", "", "", "{ENTER}")

;Send commands to close 'Finish' window

WinWaitActive($sWinTitle, "Uninstall Complete")

ControlSend($sWinTitle, "Uninstall Complete", "", "{ENTER}")

Works pretty well. I do have one more change to make though. I don't understand enough about the the global decs at the start and will have to learn more but once the script above is finished, I want to kick off the new install. The command is \\Server\ACTData\ACTINSTALL\ACTWG\setup.exe /s /f1"\\Server\ACTData\ACTINSTALL\ACTWG\SI\issconfig.iss" /f2"c:\installation_output.log".

How would I incorporate this into my script?

Once again, I appreciate your patience and apologies for the misunderstanding! :D

Petzl

Glad you're making progress. All you need is Run():
Run('\\Server\ACTData\ACTINSTALL\ACTWG\setup.exe /s /f1"\\Server\ACTData\ACTINSTALL\ACTWG\SI\issconfig.iss" /f2"c:\installation_output.log"', @TempDir)

Note the single quotes enclosing the whole string so that the double quotes will be literally included.

:o

P.S. You've been here long enough to start using the code tags in your posts, too... :D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Glad you're making progress. All you need is Run():

Run('\\Server\ACTData\ACTINSTALL\ACTWG\setup.exe /s /f1"\\Server\ACTData\ACTINSTALL\ACTWG\SI\issconfig.iss" /f2"c:\installation_output.log"', @TempDir)

Note the single quotes enclosing the whole string so that the double quotes will be literally included.

:D

P.S. You've been here long enough to start using the code tags in your posts, too... :o

Lol...found the code tag...thanks very much for all your help PsaltyDS!! :D

Share this post


Link to post
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
Sign in to follow this  
Followers 0