Jump to content
Sign in to follow this  
theak

WMIC Serial Tag Commands - CMD Show Prompt

Recommended Posts

theak

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
iamtheky

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
ViciousXUSMC

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
iamtheky

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
Chimp

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
  • Like 1

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

    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      With this script you can print Unicode text in the CMD screen
      the script is  easy to use
      just you  write the text that contains Unicode in the first input
      and the script automatically reflect the code in the second input
       you can copy the text to the clipboard
      or you can try printing the text in the CMD window
      I apologize to everyone for colors and shape if not appropriate
      I'm a blind man and I do not see
      Thank you for your understanding
      Greetings to all of youCmdUtM.au3
    • ahmet
      By ahmet
      Hello,
      I am trying to make a program that will uninstall some software, provided by some form of a list. I have this
      ; Generated by AutoIt Scriptomatic June 08, 2010 ;#RequireAdmin $sPartialName="java" $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" ;$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") ;$objWMIService=ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $objWMIService=ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems If StringInStr($objItem.Name,$sPartialName)=1 Then ConsoleWrite("Full name:" & $objItem.Name & @CRLF) RunAs("USERNAME",@ComputerName,"PASSWORD",0,@ComSpec & " /c" & ' wmic product where name="Java 9.0.4 (64-bit)" call uninstall /nointeractive',"C:\WINDOWS\system32\wbem",@SW_MAXIMIZE) ;Run('wmic product where name="Java 9.0.4 (64-bit)" call uninstall /nointeractive',"",@SW_MAXIMIZE) ExitLoop EndIf Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Product" ) Endif The script above fails uninstalling software despite providing username and password for admin account. If I run script with admin rights then the software gets uninstalled.
      At the following link there is a script by JLogan3o13 but it does not either uninstall software, unless run as admin..
      Is there some way to uninstall software using wim or wimc by providing user name and password?
       
    • Tippex
      By Tippex
      How can I detect when a Command Prompt window has returned to idle with prompt for the next command please?
      For example, after a large paste:
                              ControlClick("[CLASS:ConsoleWindowClass]", "", "", "right")
                              ControlSend("[CLASS:ConsoleWindowClass]", "", "", "p") 
      a large paste may be something like copying some large files which may go on for some time after the paste command has been given.
       
       
       
    • Simpel
      By Simpel
      Hi.
      Thanks to this post (https://www.autoitscript.com/forum/topic/189553-writing-to-cmd/?do=findComment&comment=1361142) I can now write a helpfile to the cmd when for instance passing parameter -h or -help at cmd. But then cmd is blocked by the script (I had to free it with CTRL+BREAK):
      #include <WinAPI.au3> _WinAPI_AttachConsole() $hConsole = _WinAPI_GetStdHandle(1) _WinAPI_WriteConsole($hConsole, "Print helpfile................" & @CRLF) Inside MSDN Library then I found this sentence: A process can use the FreeConsole function to detach itself from its console.
      But I don't find something like _WinAPI_FreeConsole(). How can I do it in another way?
      Regards, Conrad
    • TheAutomator
      By TheAutomator
      A fullscreen console with custom commands!

      Introduction:
      Hi everyone!
      This funny project started as a question in the help section:
      https://www.autoitscript.com/forum/topic/174404-edit-detect-key-before-updating-content/
      I'd like to share this script with everyone that is interested. 
       
      Why would I want it?
      You like the old style fullscreen console (like in the old day's), You can add custom commands, You can customize the font a lot more compared to cmd.exe, You can share ideas or add tweaks to the script.  
      Still to do:
      Write a simple custom programming language to implement this tool. Writing a little help file / pdf to describe my little programming language. Add little sound effects like a beep if there is a syntax error (optional). Clean up and modify Console.Au3 content. Add an option to have to type a login password (optional). Make an optional installer that also gives scripts for this tool a custom icon and open with command. ...Call Neo?  
      Thanks to:
      xxaviarxx: debugging, some ideas. jguinch: debugging, adding a bunch of tweaks and ideas. kylomas: debugging, new ideas.  
      Edits and updates:
      Added usage of tab key in edit control Edit has focus now on startup I'm currently rewriting a simple custom programming language to implement this tool.  
      UDF download: Console.au3
       
      Regards
      TheAutomator
×

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.