mcsdex2 Posted December 24, 2012 Share Posted December 24, 2012 Local $answer = InputBox("Question", "Uptime for what Computer?", "", "", _ - 1, -1, Default, Default) $boottime = '"Boot Time"' Local $foo = Run (@ComSpec & " /k" & "systeminfo.exe /s" & " " & $answer & " | Find " & $boottime, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD ) Local $line SplashTextOn ("Retrieving Information", "Please wait ...", 200, 100, -1, -1, 32, "Georgia", 10) ProcessWaitClose ($foo) SplashOff () While 1 $line = StdoutRead($foo) If @error Then ExitLoop MsgBox(0, "Success Return UpTime:", $answer & " Last " & $line ) Wend While 1 $line = StderrRead($foo) If @error Then ExitLoop MsgBox(0, "Failure Return Uptime:", $answer & " " & "Computer cannot be found!") Wend I am wondering if someone could point me in the right direction as I cannot seem to just capture the first line of the run command output to a msgbox. There is the script and if you have questions please ask as I think I may need to re-write it to a text file first then append it from there. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 24, 2012 Developers Share Posted December 24, 2012 This & " /k" & "systeminfo.exe /s" is missing a space after the K and should be & " /k systeminfo.exe /s". SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
kylomas Posted December 25, 2012 Share Posted December 25, 2012 mcsdex2, I would create a variable of all output instead of piping the output through the find command. This will let you interrogate additional values more easily. Like this... #include <constants.au3> #include <array.au3> Local $answer = InputBox("Question", "Uptime for what Computer?", "", ""), $cmd_output, $line Local $foo = Run(@ComSpec & " /k " & "systeminfo.exe /s " & $answer, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) SplashTextOn ("Retrieving Information", "Please wait ...", 200, 100, -1, -1, 32, "Georgia", 10) ProcessWaitClose ($foo) SplashOff () While 1 $line = StdoutRead($foo) If @error Then ExitLoop if stringlen($line) > 0 then $cmd_output &= $line WEnd While 1 $line = StderrRead($foo) If @error Then ExitLoop if stringlen($line) > 0 then $cmd_output &= $line WEnd local $boottime = stringregexp($cmd_output,'Boot Time.*',3) if @error = 0 then ConsoleWrite($boottime[0] & @LF) Else ConsoleWrite('Not Found' & @LF & $cmd_output & @lf) endif kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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