Sign in to follow this  
Followers 0
stg68

ProcessWaitClose($iPID,10). Unable to catch Return Value Success (1)

3 posts in this topic

AutoIT v3.3.10.2. Win7 64-bit

 

Problem Description:
@error returns 0 if $iPID closed before timeout reached. Expected not 0.
Based on help:
“Failure: 0 if the wait timed out” ;and this works.
“Success: 1 and sets @extended to the exit code of the process.”; cannot catch 1 (or not @error=0)

 

Goal:
Distinguish between 10 seconds timeout reached and $iPID closed prior to 10 seconds timeout

Seems like I am missing something. Thank you for your help!

 

 

#include <MsgBoxConstants.au3>
$iPID = Run("notepad.exe")
ProcessWaitClose($iPID, 10)
If @error = 0 Then
    MsgBox($MB_SYSTEMMODAL, "", "Timeout reached! Notepad was running more than 10 seconds") ; this works
Else
    MsgBox($MB_SYSTEMMODAL, "", "Notepad was closed prior to 10 seconds timeout");  this does not. Was expecting @error<>0
EndIf

 

 

 

Share this post


Link to post
Share on other sites



You need to test the returned value, not the @error. The script should be:

$iPID = Run("notepad.exe")
$rc = ProcessWaitClose($iPID, 10)
If $rc = 0 Then
    MsgBox($MB_SYSTEMMODAL, "", "Timeout reached! Notepad was running more than 10 seconds") ; this works
Else
    MsgBox($MB_SYSTEMMODAL, "", "Notepad was closed prior to 10 seconds timeout");  this does not. Was expecting @error<>0
EndIf

Jos


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

Share this post


Link to post
Share on other sites

Thank you so much!

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