TecGuy Posted September 19, 2009 Share Posted September 19, 2009 I want to run the following script until either the count reaches 10 or "Program.exe" Returns a value of 0 I just cant seem to get the script to work. For $i = 1 to 10 If $command1 = 0 Then Local $x = 0 While 1 $command1 = RunWait(@ComSpec & " /c " & "Program.exe","",@SW_HIDE,3) MsgBox(0, "Return value is", $command1) $x += 1 If Not FileExists("c:\test.txt") Then $file = FileOpen("c:\test.txt", 2) FileWriteLine($file, @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF) FileWriteLine($file, @CRLF) FileClose($file) ExitLoop EndIf WEnd $command = Run(@ComSpec & " /c " & "Program.exe","",@SW_HIDE,3) ;<-- 3 = handle to input AND handle to output, really useful here :) EndIf Next Exit Thanks Link to comment Share on other sites More sharing options...
omikron48 Posted September 19, 2009 Share Posted September 19, 2009 (edited) You correctly set it to loop 10 times. I'm just confused with $command and $command1. Are they different variables? Here's the correction: Local $command Local $x For $i = 1 to 10 If $command1 = 0 Then $x = 0 While 1 $command1 = RunWait(@ComSpec & " /c " & "Program.exe","",@SW_HIDE,3) MsgBox(0, "Return value is", $command1) $x += 1 If Not FileExists("c:\test.txt") Then $file = FileOpen("c:\test.txt", 2) FileWriteLine($file, @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF) FileWriteLine($file, @CRLF) FileClose($file) ExitLoop EndIf WEnd $command = Run(@ComSpec & " /c " & "Program.exe","",@SW_HIDE,3) ;<-- 3 = handle to input AND handle to output, really useful here :) If $command == 0 Then ExitLoop EndIf EndIf Next Exit Edited September 19, 2009 by omikron48 Link to comment Share on other sites More sharing options...
TecGuy Posted September 20, 2009 Author Share Posted September 20, 2009 (edited) $command1 the executable that will give the value of 0 if it processed successfully. Basically i have it run in a test mode to make sure that the server it is connecting to is not down $command is the same program that will run in live mode if $command1 was successfull in connecting Edited September 20, 2009 by TecGuy Link to comment Share on other sites More sharing options...
Beege Posted September 20, 2009 Share Posted September 20, 2009 $command1 the executable that will give the value of 0 if it processed successfully. Basically i have it run in a test mode to make sure that the server it is connecting to is not down$command is the same program that will run in live mode if $command1 was successfull in connectingTry declaring $command1. Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator 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