Tofu4679 Posted January 27, 2010 Share Posted January 27, 2010 I think I have ways to make this work, but they require rewriting a bunch of code and I'd like to see if there is a simple solution that I can't see. This function is checking the status of a service on a remote machine using psservice. I'm doing it this way because I couldn't find something existing that would do this AND accept credentials for the remote machine. Sometimes it takes a while to return so I'd like to put a timer in and if it takes longer than 2 seconds just jump back to the top and try again without exiting the function. A simple GoTo would work but it doesn't exist and is taboo. The solution isn't obvious to me. I'd love to know if anyone has an idea. Thanks! Func serviceStatus($c) Dim $s = 0 $result = Run(@ComSpec & " /c psservice.exe \\" & $c & " -u <Username> -p <Password> query <ServiceName>", @SystemDir, @SW_HIDE, $STDOUT_CHILD) While 1 $line = StdoutRead($result) if @error then ExitLoop if $line <> "" then if stringmid($line, StringInStr($line, "STATE") + 11,1) = 4 Then ;parse line to find status $s = "Running" EndIf ExitLoop EndIf Wend StdioClose($result) Return $s EndFunc Link to comment Share on other sites More sharing options...
JohnOne Posted January 27, 2010 Share Posted January 27, 2010 Hi mateIf it were available, where would you put the goto, and what line would you have it go ? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 27, 2010 Share Posted January 27, 2010 Also, if you restart the program, you'll still have the first one running won't you? Link to comment Share on other sites More sharing options...
JohnOne Posted January 27, 2010 Share Posted January 27, 2010 Im not certain about this, and Im guessing you would want to start from the top of the function.Perhaps you just add the lineserviceStatus($c) wherever you imagine a goto ought to be. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Tofu4679 Posted January 27, 2010 Author Share Posted January 27, 2010 I actually figured out some logic that would work, but thanks guys. Just needed my brain to start working... Link to comment Share on other sites More sharing options...
James Posted January 27, 2010 Share Posted January 27, 2010 GoTo is not in AutoIt any more because it will result in a mess, even used by the best. If you want to recall your function, then just do so inside of it. Func serviceStatus($c) Dim $s = 0 $result = Run(@ComSpec & " /c psservice.exe \\" & $c & " -u <Username> -p <Password> query <ServiceName>", @SystemDir, @SW_HIDE, $STDOUT_CHILD) While 1 $line = StdoutRead($result) if @error then ExitLoop if $line <> "" then if stringmid($line, StringInStr($line, "STATE") + 11,1) = 4 Then ;parse line to find status $s = "Running" EndIf ExitLoop EndIf Wend ; Want to call the function here? ; servceStatus("val") StdioClose($result) Return $s EndFunc Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ 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