Jump to content

Reading from cmd


Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...