Jump to content

WMIC Serial Tag Commands - CMD Show Prompt


 Share

Recommended Posts

Trying to make a script where it will run a command to show me the model name AND serial tag info on a laptop remotely and copy it to keyboard step by step. I know how to do this via WMIC but I'm curious how to create a CMD script out of it so I can just one click. So it would look something like....

  1. wmic csproduct get name
  2. *copy to clipboard* "Press enter to advance"
  3. [Enter]
  4. wmic csproduct get identifyingnumber
  5. *copy to clipboard* "Finished"

Any ideas?

Link to comment
Share on other sites

could do it with a cmd, but provide your endgame with this info as there are plenty of other ways to get it rather than dos prompts.

#RequireAdmin

$iPid = run("powershell (get-CimInstance Win32_ComputerSystem -property * | select Model,Name | format-list |  out-string).trim()" , "" , @SW_HIDE , 0x2)

$sOutput = ""

 While ProcessExists($iPid)
        $sOutput &= StdoutRead($iPID)
 WEnd

clipput($sOutput)
msgbox(0, '' , $sOutput)

 

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

If you go powershell you will probably user Win32_Bios to get the serial number as its not included in Win32_ComputerSystem.

I think what boththose posted can safely be shortened to this.

#RequireAdmin

$iPid = run("powershell (get-CimInstance Win32_ComputerSystem | fl Model, Name | out-string).trim()" , "" , @SW_HIDE , 0x2)

$sOutput = ""

 While ProcessExists($iPid)
        $sOutput &= StdoutRead($iPID)
 WEnd

clipput($sOutput)
msgbox(0, '' , $sOutput)

To run it remotely you can try invoke-command or add -computername to your get-ciminstance but the remote computer needs to have the proper services or permissions enabled for remote powershell.  

Link to comment
Share on other sites

hell yeah, my ps skills are infantile, and our computer names happen to be our serials.  here it is combined into one line, and with Get-wmiobject as that and ciminstance are fairly interchangeable in my exploring so far.

#RequireAdmin

$iPid = run("powershell (Get-WmiObject Win32_BIOS | fl SerialNumber | out-string).trim() ; (Get-WmiObject Win32_ComputerSystem | fl Model | out-string).trim()" , "" , @SW_HIDE , 0x2)

$sOutput = ""

 While ProcessExists($iPid)
        $sOutput &= StdoutRead($iPID)
 WEnd

msgbox(0, '' , $sOutput)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

if you want to query a remote client, you have to use /node:ClientName and if necessary also /user:userid and /password:pass

Local $sClientName = "clientname"
Local $sUserID = "userid" ; or $sClientName & "\userid" if is a user of the remote client
Local $sPassword = "YourPass"
Local $sOutput = "", $STDERR_MERGED = 8

Local $sWMICquery = "wmic /node:" & $sClientName & " /user:" & $sUserID & " /password:" & $sPassword & " csproduct get Name, identifyingnumber /format:value"
; local $sWMICquery = "wmic /node:" & $sClientName & " csproduct get Name, identifyingnumber /format:value" ; using current user's credentials

Local $iPID = Run($sWMICquery, "", @SW_HIDE, $STDERR_MERGED)
While ProcessExists($iPID)
    $sOutput &= StdoutRead($iPID)
WEnd
$sOutput = StringReplace(StringStripWS(StringStripCR($sOutput), 7), @LF, @CRLF) ; remove extra @CR and @LF
ClipPut($sOutput) ; result goes to clipboard
MsgBox(0, $sClientName, $sOutput)

 

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

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

×
×
  • Create New...