Jump to content
Sign in to follow this  
roofninja

saving output from runwait into a variable

Recommended Posts

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 !!!

Share this post


Link to post
Share on other sites

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...")

Share this post


Link to post
Share on other sites

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 by MHz

Share this post


Link to post
Share on other sites

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 !!!

Share this post


Link to post
Share on other sites

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. :)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...