Jump to content

Valid Windows Process ID range


Recommended Posts

Hi,

I want to do a check on whether or not an Error Occurs after this statement is issued:

$rtn_code = Run(@ComSpec & " /c " & $cmd, $pgm_dir, "")

According to the documentation, the $rtn_code will be the PID of the process spawned or an error code generated by the execution of the command.

In order to put a correct check for an error, I need to know what the lowest possible PID that is valid for Windows. Thus if the value is below this number, it is an Error Code and not a PID.

Thanx

Link to comment
Share on other sites

Hi,

I want to do a check on whether or not an Error Occurs after this statement is issued:

$rtn_code = Run(@ComSpec & " /c " & $cmd, $pgm_dir, "")

According to the documentation, the $rtn_code will be the PID of the process spawned or an error code generated by the execution of the command.

In order to put a correct check for an error, I need to know what the lowest possible PID that is valid for Windows. Thus if the value is below this number, it is an Error Code and not a PID.

Thanx

Alternatively, what is the maximum value that an Error Return Code can be from a program - then anything above that number would be a process....

Link to comment
Share on other sites

Alternatively, what is the maximum value that an Error Return Code can be from a program - then anything above that number would be a process....

Windows XP SYSTEM error codes go from 0 - 14080. PIDs will fall within that range.

[sub]Quantum mechanics: The dreams stuff is made of[/sub]

Link to comment
Share on other sites

It should return zero in the event of failure...and @ERROR will be set.

I generated an error in the parameters used in the TSHARK command being sent to CMD.

The @error value remained at 0

The Return Code from RUN was the PID.

If I use the RUNWAIT function then I get 0 if the command ran without error and I get the Error Number if the command fails. I am trying to get this functionality with the RUN command.

What I am trying to accomplish is to ALLOW the user to a window in which to interact with the script when processing several consecutive commands.

If I only use the RUNWAIT, the user's interaction is not seen by the script.

Link to comment
Share on other sites

To run DOS (console) commands, try Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)

After running the requested program the script continues. To pause execution of the script until the spawned program has finished use the RunWait function instead.

By default the script will terminate with a fatal error if the Run function fails. To set @error 1, @extended to GetLastError() Windows API and return 0 as an indication of failure, see AutoItSetOption.

Maybe try Opt("RunErrorsFatal", 0)

Link to comment
Share on other sites

Thanx for the informaton - this means that I can not distinguish between a PID and an Error Code returned from a process then, correct?

Correct, what I was referring to here was just standard system error codes.

The return error code (which few programs ever use anymore) is a 32 bit integer in Visual C++. Technically a program can return up to 2^31-1.

What Richard Robertson said is technically the correct answer.

Edited by MattWise

[sub]Quantum mechanics: The dreams stuff is made of[/sub]

Link to comment
Share on other sites

Thanx everyone for you input.

What I was attempting to do was to determine a ProcessID for a process initiated by the RUNWAIT statement. I wanted to do this to KILL this process at the user's discretion after the process had started.

What I found out was that AUTOIT will not look for User Interaction until the RUNWAIT has finished (thus the name RUNWAIT).

I then attempted to use the 'RUN" command with a 'POLL' loop waiting for when the process had finished and looking for user interaction.

In this case I could not determine if the process ended successfully or with an error.

My solution was to add a 'CHECKBOX' that is checked after the process has completed executing and if checked stop executing the next in the list.

Does anyone have a way of accomplishing this task?

Thanx

Link to comment
Share on other sites

You are very confused...

Run() returns ProcessID

RunWait() returns exit code

If you need to get the exit code of a process using Run() you must use this UDF:

http://www.autoitscript.com/forum/index.php?showtopic=23096

Okay then how Can I determine if a ProcessID created by the RUN command terminates with 'not normal' return/exit code?

Thanx for clearing up the confustion!

Link to comment
Share on other sites

Okay then how Can I determine if a ProcessID created by the RUN command terminates with 'not normal' return/exit code?

Thanx for clearing up the confustion!

Well you test with RunWait()...

$exitcode = RunWait()

MsgBox(0,"",$exitcode)

Whatever the exit code is when its successful you write that down...if it fails write that down, force it to close if you have to.

Link to comment
Share on other sites

Well you test with RunWait()...

$exitcode = RunWait()

MsgBox(0,"",$exitcode)

Whatever the exit code is when its successful you write that down...if it fails write that down, force it to close if you have to.

You are correct in that RUNWAIT returns an ExitCode.

What i am trying to accomplish is to give the user the ability to effectively kill a Process spawned by AUTOIT.

As I noted above, RUNWAIT does not work as the script will not accept user input while it is WAITING.

Thus I need to use the RUN command and the loop waiting for the process to finish.

The issue with the RUN command is that the value returned is a Process ID.

How can I determine if an 'ERROR' code is generated by the process being executed like that of RUNWAIT shown above?

Thanx

Link to comment
Share on other sites

Wow we are not on the same wavelength. You use RunWait() to determine all of the possible exit codes based on your program running successfully or unsuccessfully. This is for testing ONLY!

You need to remember the various exit codes for use with Run() and the function I posted for you.

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...