Sign in to follow this  
Followers 0
davezub

Capture exe Errorlevel without using RunWait

5 posts in this topic

Ok I realize that you can use runwait to grab an errorlevel, however, I have a requirement that I have to use run for a program. Basically this is what I'm doing:

1. Installing XP SP2

2. I'm running update.exe and then turning off the the cancel button using controldisable.

Is there any way to grab the errorlevel from update without using runwait? Here is the snippet of code:

;Run Update returns the PID Program ID to a var
$Pid = Run($XPSP2Command,$XPSP2Folder )
WriteLogFile ("Start XP SP2 Install")
;Waits for XPSP2 Window to Popup
WinWait($XPSP2Windowtitle)
;Disables the Cancel and Help Buttons
ControlDisable($XPSP2Windowtitle,"Cancel", 2)
ControlDisable($XPSP2Windowtitle,"Help", 9)
WriteLogFile ("Disable Buttons")
;Waits for PID to close
ProcessWaitClose($Pid)
WriteLogFile ("Stop XP SP2 Install")

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What about doing it this way: The script start itself again with a parameter so the second instance disables the button for you?

Here is the scriptlet which will only work when it is compiled:

If $cmdline[0] = 1 and $cmdline[1] = "extras" then 
;Waits for XPSP2 Window to Popup
 WinWait($XPSP2Windowtitle)
;Disables the Cancel and Help Buttons
 ControlDisable($XPSP2Windowtitle,"Cancel", 2)
 ControlDisable($XPSP2Windowtitle,"Help", 9)
 WriteLogFile ("Disable Buttons")
 Exit
EndIf
;Run Itself as Update returns the PID Program ID to a var
Run(@ScriptFullPath & " extras",@ScriptDir)
;Run Update returns the PID Program ID to a var
WriteLogFile ("Start XP SP2 Install")
$RC = RunWait($XPSP2Command,$XPSP2Folder )
WriteLogFile ("Stop XP SP2 Install:" & $RC)
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

...I'm running update.exe...

JdeB has given you a great work around for the path that you were taking.

You might want to look into unattended installation of XP SP2 as described here:

http://www.microsoft.com/technet/prodtechn...y/spdeploy.mspx

...or maybe not.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks nice resource but still does not cure Microsoft's oversight of displaying the cancel button when using /passive. What are most users going to do hit cancel. I thought about a custom message and using runwait with /quiet but I want to provide feedback to the user about what's going on since this is a lenghty install.

JdeB has given you a great work around for the path that you were taking.

You might want to look into unattended installation of XP SP2 as described here:

http://www.microsoft.com/technet/prodtechn...y/spdeploy.mspx

...or maybe not.

Share this post


Link to post
Share on other sites

...Microsoft's oversight of displaying the cancel button when using /passive.

I did not know that... Thanks for the info. Your script(s) should solve that.

have fun


[size="1"][font="Arial"].[u].[/u][/font][/size]

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