Jump to content
Sign in to follow this  
theak

WMIC Serial Tag Commands - CMD Show Prompt

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?

Share this post


Link to post
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

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

Share this post


Link to post
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.  

Share this post


Link to post
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)

 


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

Share this post


Link to post
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

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

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  

  • Similar Content

    • By KingOfNothing
      This is for mac address spoofing.
      Before a mod gives me the ban hammer for posting code such as this, id like to explain I recently had a necessity for it.
      A lot of places use mac addresses to identify devices/machines and control internet permissions.
      I myself love the xfinity wifi hotspots placed all around where I live as I can connect to them and save data usage instead of tethering my phone.
      BUT! They use a captive portal with a webpage interface in javascript and (not too much to my surprise), wifey says some of her crap wont open that page.
      I explained she can disable wifi on the device, use computer and spoof to the mac address of what she wants to use. Then sign into the portal as she would normally with computer.
      Once connected, shut the computer down and enable wifi for that device again. Once enabled shes got net access. edit: Wife looked at me like I was speaking latin.....lol
      ; ; ; Function: Set_Mac() ; ; Parameter(s): $s_Desired_Mac = Need I really explain? ; $s_Target_Net_Adapter = Network adapter name (one can use the adapter index as well but thats less "user friendly" ; $b_Toggle_Device = For my wife cuz it needs full automation for her to stop bothering me ; ; Author(s): KingOfNothing credz to google & autoitscript.com members ; ; ;===================================================================== Opt('MustDeclareVars', 0) ;cause its late in the morning and im just gonna trust this should still fly #include <WinApi.au3> $MacAddressRegKey = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0007" ; ^^^ After making this I read online that this should be some "CurrentControlSet" ; key instead. However, I watched registry while changing things in adapter properties ; to see that key, which works fine on my 3 test machines.... ;easy example Set_Mac("Wireless Network Connection","",true) ;msgbox(0,"",Get_Mac()) Func Set_Mac($s_Targeted_Adapter, $s_Desired_Mac = "D20000000000", $b_Toggle_Device = true ) Local $sMac, $s_Tmp, $val, $sVar = "" $sMac = Get_Mac() while stringlen($s_Desired_Mac)< 12 and stringlen($s_Desired_Mac)> 0 ;this will append zeros if mac length is too short $s_Desired_Mac = $s_Desired_Mac & "0" wend if stringlen($s_Desired_Mac)> 12 then ;likewise if too many characters entered to function, then we should truincate some $s_Desired_Mac = StringLeft ($s_Desired_Mac,12) endif ;this creates a random mac address with very little actual thought behind it. ;Im sure theres some formal means to devising a valid mac address but this simple crap suits my needs atm.... if $s_Desired_Mac = "" then For $i = 1 To 10 $sVar= Chr(Random(48, 57, 1)) ;0-9 $s_Tmp = $s_Tmp & $sVar Next $s_Desired_Mac = "D2" & $s_Tmp $s_Desired_Mac = StringUpper($s_Desired_Mac) endif $val = RegWrite($MacAddressRegKey, "NetworkAddress", "REG_SZ", $s_Desired_Mac) if $val =0 then MsgBox(0,"Mac Address Changer ","Could not write to registry as needed to change your mac address!" & @CRLF & "Please restart this program with administrator rights!") Exit endif ;in order to benifit from changing the registry, one must disable/re-enable the adapter. ;This cmd line query to wmic prevents the need to do so in device manager manually if $b_Toggle_Device = true then ShellExecuteWait ("C:\Windows\System32\wbem\wmic.exe", "path win32_networkadapter where NetConnectionID=" & chr(34) & $s_Targeted_Adapter & chr(34) & " call disable" ,"",$SHEX_OPEN,@SW_HIDE) ShellExecuteWait ("C:\Windows\System32\wbem\wmic.exe","path win32_networkadapter where NetConnectionID=" & chr(34) & $s_Targeted_Adapter & chr(34) & " call enable" ,"",$SHEX_OPEN,@SW_HIDE) endif ;Would be smart to catch the return of the function there in some varible for error handling, but its too late for me to give a crap atm.... MsgBox(0,"Mac Address Changer", "Old Mac = " & $sMac & @crlf & "New Mac = " & $s_Desired_Mac) clipput($s_Desired_Mac) endfunc Func Get_Mac() Local $xRet $xRet= RegRead($MacAddressRegKey, "NetworkAddress") return $xRet EndFunc  
      Sorry bout the messy penmenship. Aint looked at the tidy thing yet....🧐
    • By Burgs
      Greetings,
        I would like to be able to write a script to send commands to the console for creation of Gstreamer pipelines.  I was thinking of something similar to this:
      Local $iPID = Run("C:\Windows\System32\cmd", "", @SW_MAXIMIZE) ;THIS OPENS THE CONSOLE...!!! if $iPID == 0 Then ConsoleWrite(@CRLF & "I DID NOT OPEN CMD...error: " & @error & @CRLF) if $iPID <> 0 Then ConsoleWrite(@CRLF & "I OPENED CMD...!!!" & @CRLF) $hCmd = WinGetHandle("C:\WINDOWS\system32\cmd.exe") if $hCmd <> 0 Then WinActivate($hCmd) ;ensure command console is active... $sOutput = Send("cd C:\gstreamer\1.0\x86_64\bin" & @CRLF, $SEND_RAW) $sOutput = Send("gst-launch-1.0 videotestsrc ! autovideosink" & @CRLF, $SEND_RAW) Sleep(3000) ControlSend($hCmd, "", "", "exit" & @CR) EndIf ;$hCmd NOT "0"... I don't really know if this is the best way to open the console and send commands into it.  I'm also not sure about how to best catch any errors that may occur...likely this needs to be accomplished with the STDOUTREAD command however I've not had experience using it before and therefore would appreciate some advice that anybody may offer. 
      Basically I'm seeking guidance on how to best automate the opening of the console, sending lines of commands to be executed, and handling any potential errors in the execution of those commands...I thank you in advance.  Regards.
    • By nitron
      Hy All,
       
      again I got a question.
      I try to convert
      wmic PATH Win32_videocontroller GET adapterram
       
      i tried to to it like in this example but my knoledge is not good enough
         Local $oWMI = ObjGet("winmgmts:root\CIMV2")
         Local $oDisks = $oWMI.ExecQuery("select * from WIN32_DiskDrive")
       
      So i tired 
         Local $oWMI = ObjGet("winmgmts:root\CIMV2")
         Local $oGMRam= $oWMI.ExecQuery("Win32_videocontroller")
         $Memory=$oGMRam.adapterram
      but this does not work.
      I like to understand what i need to do?
       
    • By MadhaN
      Hi all,
      I have a csv file as below, I wand to find srno from csv and send corresponding ip and pass to commend cmd prompt. 
      Please guide me to create script .
      srno,name,ip,pass
      1,name1,ip1,pass1
      2,name2,ip2,pass2
       
       
       
       
    • By Fortitude
      Hello!
      I have made a program, that opens a folder, and then store the path ("C:\programFiles\etc") in a variable.
      Then i need to open the command panel as administrator, and write  in the stored path, and some other text.

      Can i somehow instantly copypaste the text i needed, instead of writing in the command panel with the Send commands?
       
      #RequireAdmin #include <MsgBoxConstants.au3> Global Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Global $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "Nem választottál ki mappát!") Exit EndIf Global $Tiff_path = $sFileSelectFolder & "\TiffChecker_2_32" FileCopy( "C:\TiffChecker_2_32.exe" , $sFileSelectFolder) $CMD = $Tiff_path & " " & $sFileSelectFolder & " /s/d" Run("C:\WINDOWS\system32\cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send($CMD) Sleep(1000) Send("{ENTER}") sleep(1000) MsgBox(0,"Press OK", "Press OK to continue") FileCopy("C:\Tiffchecker.txt", $sFileSelectFolder) Also, how do i close the command panel, when the program is finished? (usually its under 1 second, so after the send i just put a Sleep function there)
×
×
  • Create New...