Jump to content



Recommended Posts


Oh this func is only a litte thing, not realy great! But i need it often.. so ive written a Func and now i will give it to you :)

$RunRead = _RunWait("cmd","",@SW_HIDE,2,1000)
If @error = 1 Then Exit MsgBox(16,"Error 1","Das Programm hat ein Error ausgegeben (StdErr):"&@crlf&@crlf&$RunRead)
If @error = 2 Then Exit MsgBox(16,"Error 2","Das Programm hat ein  timeout mit Error ausgabe (StdErr):"&@crlf&@crlf&$RunRead)
If @error = 3 Then Exit MsgBox(48,"Error 3","Das Programm hat ein timeout mit ganz normaler ausgabe (StdOut:)"&@crlf&@crlf&$RunRead)
MsgBox(0,"All Ok!",$RunRead)
; Function Name:   _RunWait
; Description::    Wait until exe Closes, like RunWait but with _RunWait it will return the Std I/O stream, and you can take a TimeOut!
; Parameter(s):     $sExe: Name of File (EXE, BAT, COM, PIF)
;           $sWorkindir: [optional] The Workin dir (see Run in autoit Helpfile)
;           $sFlag: [optional] The Flag (see Run in autoit Helpfile)
;           $iIOFlag: [optional] Provide a meaningful handle to one or more STD I/O streams of the child process. (see Run in autoit Helpfile)
;           $iTimeOut: [optional] TimeOut in milliseconds! I've the programm run longer then the time out the programm will close (ProcessClose)
; Requirement(s):  -
; Return Value(s): On Succes: Return a StdOutread of the programm
;           On Error: 
;           @error = 1: The Programm has Returnd an error with StdErr
;           @error = 2: The Programm has a Time out with error (StdErr) Return
;           @error = 3: The Programm has a Time out with normal StdOut Return (StdErr) ReturnDas Programm hat ein timeout mit ganz normaler ausgabe (StdOut)
; Author(s):       GtaSpider

Func _RunWait($sFilename,$sWorkingdir="",$sFlag="",$iIOFlag="",$iTimeOut=0)
    Local $pid = Run($sFilename,$sWorkingdir,$sFlag,$iIOFlag)
    If $iTimeOut Then $timer = TimerInit()
    While ProcessExists($pid)
        If $iTimeOut Then
            If TimerDiff($timer) >= $iTimeOut Then ExitLoop
    If ProcessExists($pid) Then
        If StderrRead($pid) <> "" Then Return SetError(2,0,StderrRead($pid))
        Return SetError(3,0,StdoutRead($pid))
    If StderrRead($pid) <> "" Then Return SetError(1,0,StderrRead($pid))
    Return StdoutRead($pid)

Mfg/best regards Spider

www.AutoIt.de - Moderator of the German AutoIt Forum


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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...