GtaSpider Posted January 16, 2007 Share Posted January 16, 2007 Hello! 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 expandcollapse popup$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) Sleep(50) If $iTimeOut Then If TimerDiff($timer) >= $iTimeOut Then ExitLoop EndIf WEnd If ProcessExists($pid) Then ProcessClose($pid) If StderrRead($pid) <> "" Then Return SetError(2,0,StderrRead($pid)) Return SetError(3,0,StdoutRead($pid)) EndIf If StderrRead($pid) <> "" Then Return SetError(1,0,StderrRead($pid)) Return StdoutRead($pid) EndFunc Mfg/best regards Spider www.AutoIt.de - Moderator of the German AutoIt Forum Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now