roofninja Posted March 31, 2008 Share Posted March 31, 2008 I have some code here that works, but I don't like it because it slows down the big program that it is in. The lines that are commented out is an attempt to get the output of the runwait into a variable. I know that there has to be a better way but I am not finding it in the help files or in the forums. Can you point me in the right direction? Thanks for the help. RunWait(@ComSpec & " /c " &"chkcpu32 /s>cpu.txt",@ScriptDir&"\test",@SW_HIDE);this get cpu info short and only cpu name. ;$pro = RunWait(@ComSpec & " /c " &"chkcpu32 /s",@ScriptDir&"\test",@SW_HIDE);this get cpu info short and only cpu name. $processor = stringReplace(StringStripWS(RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","ProcessorNameString"),1),"(R)","",0,0) if @error or $processor = "" Then ;$processor = $pro $file3 = FileOpen(@ScriptDir&"\test\cpu.txt", 0) $processor = FileReadLine($file3) FileClose($file3);for cpu.txt EndIf MsgBox(16,"test","Your processor is _:"&$processor) RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!! Link to comment Share on other sites More sharing options...
Zedna Posted March 31, 2008 Share Posted March 31, 2008 Example for StdoutRead() from helpfile: ; Demonstrates StdoutRead() #include <Constants.au3> $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($foo) If @error Then ExitLoop MsgBox(0, "STDOUT read:", $line) Wend While 1 $line = StderrRead($foo) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) Wend MsgBox(0, "Debug", "Exiting...") Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
MHz Posted March 31, 2008 Share Posted March 31, 2008 (edited) Try this concept $pid = Run(@ComSpec & " /c chkcpu32 /s", @ScriptDir & "\test", @SW_HIDE, 2);this get cpu info short and only cpu name. ;$pro = RunWait(@ComSpec & " /c " &"chkcpu32 /s",@ScriptDir&"\test",@SW_HIDE);this get cpu info short and only cpu name. $data = "" Do $data &= StdOutRead($pid) Until @error $processor = StringReplace(StringStripWS(RegRead("HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString"), 1), "(R)","", 0, 0) if @error or $processor = "" Then $processor = $data ;$file3 = FileOpen(@ScriptDir&"\test\cpu.txt", 0) ;$processor = FileReadLine($file3) ;FileClose($file3);for cpu.txt EndIf MsgBox(16,"test", "Your processor is _:" & $processor) Edit: Changed "$processor = $pid" to "$process = $data". Edited April 1, 2008 by MHz Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 31, 2008 Share Posted March 31, 2008 RunWait returns the system error code, not the console output. Link to comment Share on other sites More sharing options...
roofninja Posted March 31, 2008 Author Share Posted March 31, 2008 Try this conceptI tried what you did but I all I got was numbers. RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!! Link to comment Share on other sites More sharing options...
roofninja Posted March 31, 2008 Author Share Posted March 31, 2008 Example for StdoutRead() from helpfile:Thanks for the example. I haven't got what I want from it yet. I will have to play with it more when I have more time.My problem now with the example is I can't seem to get the output into an array or variable that will display it all at once. It breaks the output into 2 or 3 parts. RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!! Link to comment Share on other sites More sharing options...
MHz Posted April 1, 2008 Share Posted April 1, 2008 I tried what you did but I all I got was numbers.Ah, I repaired the code example above to display the data of what you want I hope. 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