theak Posted August 3, 2015 Posted August 3, 2015 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....wmic csproduct get name*copy to clipboard* "Press enter to advance"[Enter]wmic csproduct get identifyingnumber*copy to clipboard* "Finished"Any ideas?
iamtheky Posted August 3, 2015 Posted August 3, 2015 (edited) 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 August 3, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
ViciousXUSMC Posted August 3, 2015 Posted August 3, 2015 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.
iamtheky Posted August 3, 2015 Posted August 3, 2015 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) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Gianni Posted August 3, 2015 Posted August 3, 2015 (edited) if you want to query a remote client, you have to use /node:ClientName and if necessary also /user:userid and /password:passLocal $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 August 3, 2015 by Chimp blemas 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now