gertsolo Posted September 5, 2008 Share Posted September 5, 2008 (edited) Hey, I'm writing a script that starts a cmd box which starts an executable: RunWait(@COMSPEC & " /c DoSomeThing " ) This executable keeps looping. I want to stop it but this is prevented with the RunWait command which....waits. The problem is that I can't run that executable once. It keeps looping in that com box. So if I just use the RUN command, the cmd box appears and dissapears immediately without running the DoSomeThing command. How can I stop that command after a time? Second question: can I run a command line in background? thx. Edited September 5, 2008 by gertsolo The more you learn, the less you know. Link to comment Share on other sites More sharing options...
rasim Posted September 5, 2008 Share Posted September 5, 2008 1.TimerInit() TimerDiff() ProcessClose()2.Run(@ComSpec & " /c dir /b c:\", @SystemDir, @SW_HIDE)CMDOW Link to comment Share on other sites More sharing options...
gertsolo Posted September 8, 2008 Author Share Posted September 8, 2008 1. TimerInit() TimerDiff() ProcessClose() Thx Rasim, I see what you mean, but where should I put that? As soon as I start the RunWait it hangs on that line, no? Or should I use the Run command with the timer, and if so, how? thx The more you learn, the less you know. Link to comment Share on other sites More sharing options...
rasim Posted September 8, 2008 Share Posted September 8, 2008 gertsoloExample:Dim $ReadOut $timer = TimerInit() $PID = Run(@ComSpec & " /c dir c:\ /b /s", @SystemDir, @SW_HIDE, 2 + 4) While 1 If TimerDiff($timer) > 1000 Then ;If timer difference more than 1 sec ProcessClose($PID) ;close process ExitLoop ;Exit from loop EndIf $ReadOut &= StdoutRead($PID) If @error Then ExitLoop WEnd MsgBox(0, "", $ReadOut) Link to comment Share on other sites More sharing options...
gertsolo Posted September 8, 2008 Author Share Posted September 8, 2008 (edited) Thanks Rasim, that totally did the job Can different command lines be run in that way. I mean within the same dos box? I need to run a few commands after each other in the same box, all in background. For example a ftp sequence: login, sending files etc... rgds, Edited September 8, 2008 by gertsolo The more you learn, the less you know. Link to comment Share on other sites More sharing options...
rasim Posted September 8, 2008 Share Posted September 8, 2008 gertsoloSomething like this:Dim $aPID[3] = [" /c dir c:\ /b /s", " /c dir d:\ /b /s", " /c dir e:\ /b /s"] ;few commands For $i = 0 To UBound($aPID) - 1 $aPID[$i] = Run(@ComSpec & $aPID[$i], @SystemDir, @SW_HIDE, 2 + 4) Next $timer = TimerInit() While 1 If TimerDiff($timer) > 1000 Then ;If timer difference more than 1 sec _Terminate($aPID) ;close process ExitLoop ;Exit from loop EndIf WEnd Func _Terminate($aPID) For $i = 0 To UBound($aPID) - 1 ProcessClose($aPID[$i]) Next EndFunc 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