1 Screenshot

About This File

Hello Everyone :), Are you tired of searching the forum for getting both the exit code & the stdout output? Then your are in the right place!


With this UDF you can get the both output & exit code of the command or the console app! Or you can get the exit code of another process without having to use RunWait...


1. Simple & Lightweight (15 KB)

2. Detailed comments & description

3. Flexible functions with many optional parameters :)

A BIG THANKS TO PsaltyDS for the functions! 2 of the (main) functions in the UDF are his work :)


List of functions:

_Process_RunCommand: Runs a command or a executable

_Process_WaitUntil: Waits until a process starts or quits. Also returns the exit code...

_Process_GetPID: Gets the PID of the process using the name of the process

_Process_GetPath: Get the path of a process along with its arguments (if any)

_Process_GetHandle: Gets the handle of a process, will be used later to retrive the exit code

_Process_CloseHandle: Closes the Process Handle of a process

_Process_GetExitCode: Gets the exit code of a process

_Process_DebugRunCommand: Debugs a command in CMD style, see the example.

What's New in Version 1.3


Added $PROCESS_DEBUG option

Changed Constant's values, they now are powers of 2 (for compatability with BitAND)

Changed _Process_RunCommand to accept $PROCESS_DEBUG, You can now debug directly using this function :)

Changed _Process_DebugRunCommand, Now you can resize it


Also some little cleanups ;)

2 people like this

User Feedback

You may only provide a review once you have downloaded the file.


  • 5
   1 of 1 member found this review helpful 1 / 1 member

Nice UDF

Share this review

Link to review

· Edited by TheDcoder

  • 5

5 Stars, Please submit your reviews too :)


P.S Feel free to vote 3 stars :lol:

Share this review

Link to review
  • Similar Content

    • TLOTS
      By TLOTS
      I'm triying to get the session id to close automatically a RDP session.
      I tried doing this:
      #RequireAdmin #include <Constants.au3> $DOS = Run('C:\Windows\System32\query.exe user', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;Run(@ComSpec & " /c " & 'Query User', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;Run(@ComSpec & " /c " & 'quser', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($DOS) $Message = StdoutRead($DOS) MsgBox(0,'',$Message) But the $Message is always empty, if I execute any of these commands in a cmd window, it works
      Any idea on why is this falling? there is another way to get this info?
      PS: Sorry for my english, i'm not native.
    • fopetesl
      By fopetesl
      I have problems running both Bat files and Command line instructions.
      This function hopefully shows what I have tried so far
      Global $fFileToCreate = "", $DOS ScanFilm($fFileToCreate) Func ScanFilm($fFileToCreate) MsgBox($MB_SYSTEMMODAL, "Scanning Status", $fFileToCreate) ; $DOS = Run(@ComSpec & " /c " & "scan.bat" & @CRLF, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $DOS = Run(@ComSpec & " /k " & "ncat 80 <scant.txt >scanrep", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ; $DOS = _RunDOS("ncat 80 <scant.txt >scanrep") ProcessWaitClose($DOS) $Message = StdoutRead($DOS) MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $Message) Endfunc My first attempt running scan.bat reveals a bug in cmd.exe where the result of
      echo !SR | ncat 80 > scanrep is
      C:\S3_GUI\ncat>scan.bat C:\S3_GUI\ncat>echo scant.txt | ncat 80 1>scanrep Ncat: . C:\S3_GUI\ncat> note the added '1' which then throws the error, (when client is connected), "File or directory not found" so the command fails.  This has been run on four different computers running Windows 7 with same result.
      Next using Run() seems to truncate the command so $DOS reads:

      Using _RunDOS() doesn't throw any error but MsgBox() is empty.

    • tcox8
      By tcox8
      Currently I am running a script that calls a powershell script. To read the results of that I am reading StdOut. I am parsing things accordingly but unfortunately it doesn't parse correctly all the time and I end up missing parts of the string or other problems. My question then is, what is the best results for reading what is returned when running a powershell script or something similar?
    • Eddi96
      By Eddi96
      Hey guys!
      I need your help again. So I am working on a Project with which I can Logoff a User in a Terminal-Server (Windows Server 2012 R2), logged in as Admin. Then backup the users partition and log him back in. Sounds pretty easy for you guys, right? So my problem is... I seem to not be able to get the User ID. You can see and display the ID in a textfile with:
      Run("query user>>c:\users\example\desktop\helpmeguys.txt") This line just writes a textfile of "query user" on the desktop. This is an example on what it looks like:
      >wg                                  console                       2  Aktiv                     17    25.07.2016 08:19

      What I need right now is the ID. Any Idea on how to read it off of the Textfile?
      Please give me examples because I am still a rookie!
      With kind regards
    • FMS
      By FMS
      I've made a GUI that can send multiple commands.
      The way I'm doing this at the moment is whit "send" commands.
      also first go to the right directory where the "to be used" program sits
      And send from there the commandline argument whit parameters.
      Here is a example of the way I'm using it now:
      Func restart_app($xip) Run("C:\WINDOWS\system32\cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Sleep(50) send("cd\" & "{ENTER}") Sleep(50) send("cd Tools" & "{ENTER}") Sleep(50) send("pskill \\" & $$xip & " -u username -p pass /accepteula app.exe" & "{ENTER}") EndFunc This way is working and I got no problems whit this.
      Also I realy think there is a mush better and way to do the same and maybe a little bit less error free
      (even better if this is hidden for the user :))
      On this forum I could not find anything related to this subject (or I was not looking in the right direction) and hope somebody knows a better way
      Is there a way where u can send the arguments and parameters directly in 1 line to the commandpromt whitout using "send" to commandprompt?
      Thanks in advanced

      ps: I also tried :
      ShellExecute("pskill", "\\" & $xip & " -u username -p pass /accepteula app.exe")

      But din't work