Jump to content
Sign in to follow this  
Rogue5099

Reading from cmd

Recommended Posts

Rogue5099

cmd line I want to run is: "wmic bios get serialnumber"

I want to be able to get this info to a variable. I tried the following:

$console = Run(@ComSpec & " /c wmic bios get serialnumber", '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

MsgBox(0, "???", StdoutRead($console))

I at least am able to see the serial number in the following but can't do nothing with it and it is too window contolling, trying to aviod Send()...

Run("cmd.exe")

Sleep(1000)

Send("wmic bios get serialnumber{ENTER}")

Edited by rogue5099

Share this post


Link to post
Share on other sites
Rogue5099

Ok i got this far:

Local $console = Run(@ComSpec & " /c wmic bios get serialnumber", @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $iError, $line, $Result = ""
While 1
    $line = StdOutRead($console)
    $iError = @error
    
    If $iError Then ExitLoop
        
    $Result = $line

    Sleep(10)
Wend
MsgBox(0, "???", $Result)

Now just need to isolate s/n....

Share this post


Link to post
Share on other sites
Rogue5099

Fixed!!!! Problem Solved, just had to work through it bymyself... If anyone knows a better way please post!

Local $console = Run(@ComSpec & " /c wmic bios get serialnumber", @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
Local $line, $Result = ""
While 1
    Sleep(100)
    $line = StdOutRead($console)
    If @error Then ExitLoop
    $Result = $line
Wend
$Result = StringTrimLeft($Result, 17)
MsgBox(0, "???", $Result)
Edited by rogue5099

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.