TSO Posted March 28, 2008 Posted March 28, 2008 I just need a script that will pop up a message box providing the serial # (I assume from BIOS) and the hostname of the PC the script is run on. Can anyone help? Thanks
weaponx Posted March 28, 2008 Posted March 28, 2008 I think this will get you the motherboard serial, is that what you're after? Dim $sAns $WMI = ObjGet("WinMgmts:") $objs = $WMI.InstancesOf("Win32_BaseBoard") For $obj In $objs $sAns = $sAns & $obj.SerialNumber If $sAns < $objs.Count Then $sAns = $sAns & "," Next $MBSerialNumber = $sAns MsgBox(0,"",$MBSerialNumber)
weaponx Posted March 28, 2008 Posted March 28, 2008 (edited) Maybe this??$strComputer = "." $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colSMBIOS = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure") For $objSMBIOS in $colSMBIOS ConsoleWrite("Part Number: " & $objSMBIOS.PartNumber & @CRLF) ConsoleWrite("Serial Number: " & $objSMBIOS.SerialNumber & @CRLF) ConsoleWrite("Asset Tag: " & $objSMBIOS.SMBIOSAssetTag & @CRLF) NextSee here for some other WMI tricks:http://msdn2.microsoft.com/en-us/library/a...587(VS.85).aspx Edited March 28, 2008 by weaponx
martin Posted March 28, 2008 Posted March 28, 2008 weaponx said: I think this will get you the motherboard serial, is that what you're after? Dim $sAns $WMI = ObjGet("WinMgmts:") $objs = $WMI.InstancesOf("Win32_BaseBoard") For $obj In $objs $sAns = $sAns & $obj.SerialNumber If $sAns < $objs.Count Then $sAns = $sAns & "," Next $MBSerialNumber = $sAns MsgBox(0,"",$MBSerialNumber) Should that be Dim $sAns $WMI = ObjGet("WinMgmts:") $objs = $WMI.InstancesOf("Win32_BaseBoard") $iCount = 1 For $obj In $objs $sAns = $sAns & $obj.SerialNumber If $iCount < $objs.Count Then $sAns = $sAns & "," $iCount += 1 Next $MBSerialNumber = $sAns MsgBox(0,"",$MBSerialNumber) Produces "None," on my old 32 bit laptop, and just a comma (without the mod to the script) on two PCs I tried. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
weaponx Posted March 28, 2008 Posted March 28, 2008 (edited) Not sure, I took the VB code from here:http://www.freevbcode.com/ShowCode.asp?ID=2664 Edited March 28, 2008 by weaponx
TSO Posted March 28, 2008 Author Posted March 28, 2008 Actually I'm looking for the computer's actual Serial #. I just assume it would be pulled from the BIOS. I'm not sure I really understand that script, I really just need it in a msgbox. I saw a script with AutoIt v2 that was perfect, had a ton of computer info when you ran it, and I remember the script being extremely simple. I just can't seem to find the damn thing
weaponx Posted March 28, 2008 Posted March 28, 2008 http://www.autoitscript.com/forum/index.php?showtopic=29404
TSO Posted March 28, 2008 Author Posted March 28, 2008 weaponx said: http://www.autoitscript.com/forum/index.php?showtopic=29404Yeah, I already saw this and it's waaaaay overkill for what I'm trying to do, and I have not the scripting knowledge to pick it apart to simply give me the host and serial. Believe me I've been trying :-X I really just need a simple msgbox, I just don't know how to populate that box with the host and serial.
weaponx Posted March 28, 2008 Posted March 28, 2008 I'm pretty sure the second script I posted took care of that.
TSO Posted March 28, 2008 Author Posted March 28, 2008 (edited) weaponx said: I'm pretty sure the second script I posted took care of that.Yeah it did, Thanks for the help, I'm just not sure how to get it to pull the machine serial instead of the motherboard. And still not sure what to throw in there to return the computer hostname.edit: n/m, I see now your second script had the PC S/N, not the Mobo.. I'll check it out, thanks Edited March 28, 2008 by TSO
TSO Posted March 28, 2008 Author Posted March 28, 2008 (edited) Ok, I just realized since I know nothing about scripting and am an idiot, your script was good, it just didn't have the msgbox, which is why I wasn't getting any output. Here is what I have now.... $strComputer = "." $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colSMBIOS = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure") For $objSMBIOS in $colSMBIOS ConsoleWrite("Part Number: " & $objSMBIOS.PartNumber & @CRLF) ConsoleWrite("Serial Number: " & $objSMBIOS.SerialNumber & @CRLF) ConsoleWrite("Asset Tag: " & $objSMBIOS.SMBIOSAssetTag & @CRLF) Next MsgBox(0,"",$objSMBIOS.SerialNumber) I'd be grateful if someone could assist with adding the computer hostname to the msgbox. If not I will try to find this on my own, I assume that will be easier than the s/n. Thanks for all your help weapon. Edited March 28, 2008 by TSO
weaponx Posted March 28, 2008 Posted March 28, 2008 There are macros for hostname... @ComputerName @UserName @IPAddress1 etc...
covaks Posted March 28, 2008 Posted March 28, 2008 Serial number can be stored in different locations depending on manufacturer. WIN32_BIOS, CIM_CHASSIS, and WIN32_BASEBOARD, and WIN32_COMPUTERSYSTEMPRODUCT are a just a few others. Also, there's no guarantee that any of those locations will contain the Serial number, I've found quite a few systems that didn't have it anywhere I looked.
TSO Posted March 28, 2008 Author Posted March 28, 2008 weaponx said: There are macros for hostname...@ComputerName@UserName@IPAddress1etc...Yes! That's what I was looking for, thanks mang. I didn't know what they were called. Now I see the entire list in the help file. Thanks.
TSO Posted March 28, 2008 Author Posted March 28, 2008 (edited) TSO said: Yes! That's what I was looking for, thanks mang. I didn't know what they were called. Now I see the entire list in the help file. Thanks.Ok, I have this now, and it works great: $strComputer = "." $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colSMBIOS = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure") For $objSMBIOS in $colSMBIOS ConsoleWrite("Serial Number: " & $objSMBIOS.SerialNumber & @CRLF) ConsoleWrite("Asset Tag: " & $objSMBIOS.SMBIOSAssetTag & @CRLF) Next MsgBox(0,"Redirect Info", "Host Name: " & @ComputerName & @CRLF & "Serial #: " & $objSMBIOS.SerialNumber & @CRLF & "Asset Tag: " & $objSMBIOS.SMBIOSAssetTag) Only question now is, is there a msgbox that will allow you to highlight and copy the lines so you can paste it somewhere else? Edited March 28, 2008 by TSO
weaponx Posted March 28, 2008 Posted March 28, 2008 covaks said: Serial number can be stored in different locations depending on manufacturer. WIN32_BIOS, CIM_CHASSIS, and WIN32_BASEBOARD, and WIN32_COMPUTERSYSTEMPRODUCT are a just a few others. Also, there's no guarantee that any of those locations will contain the Serial number, I've found quite a few systems that didn't have it anywhere I looked.True, I guess you could retrieve each one until you get a value. The second script I posted matches the serial number on my computer and what is shown in Lavalys Everest Ultimate Edition. I am running a brand new HP dc7800 w/ XP SP2.
TSO Posted March 28, 2008 Author Posted March 28, 2008 weaponx said: True, I guess you could retrieve each one until you get a value. The second script I posted matches the serial number on my computer and what is shown in Lavalys Everest Ultimate Edition. I am running a brand new HP dc7800 w/ XP SP2.Yes, fortunately we run dc7700's across the board here with a spattering of Dells (which I've already tested on and works). Thanks again. I'm not having any luck getting the output into a box that I can copy and paste from. I'm sure I can do it via a listbox in a GUI script, but have zero clue how to do that either. I need more free time to actually learn this shiz
weaponx Posted March 28, 2008 Posted March 28, 2008 (edited) $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colSMBIOS = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure") For $objSMBIOS in $colSMBIOS ;ConsoleWrite("Serial Number: " & $objSMBIOS.SerialNumber & @CRLF) ;ConsoleWrite("Asset Tag: " & $objSMBIOS.SMBIOSAssetTag & @CRLF) Next #include <GUIConstants.au3> GUICreate("System Information", 350, 100) ; will create a dialog box that when displayed is centered GUISetState (@SW_SHOW) ; will display an empty dialog box GUICtrlCreateLabel("Serial #:", 15,10) GUICtrlCreateInput($objSMBIOS.SerialNumber, 100, 10, 200, 20) GUICtrlCreateLabel("Asset tag:", 15,40) GUICtrlCreateInput($objSMBIOS.SMBIOSAssetTag, 100, 40, 200, 20) GUICtrlCreateLabel("Computer name:", 15,70) GUICtrlCreateInput(@ComputerName, 100, 70, 200, 20) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Edited March 28, 2008 by weaponx
TSO Posted March 28, 2008 Author Posted March 28, 2008 weaponx said: $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colSMBIOS = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure") For $objSMBIOS in $colSMBIOS ;ConsoleWrite("Serial Number: " & $objSMBIOS.SerialNumber & @CRLF) ;ConsoleWrite("Asset Tag: " & $objSMBIOS.SMBIOSAssetTag & @CRLF) Next #include <GUIConstants.au3> GUICreate("System Information", 350, 100) ; will create a dialog box that when displayed is centered GUISetState (@SW_SHOW) ; will display an empty dialog box GUICtrlCreateLabel("Serial #:", 15,10) GUICtrlCreateInput($objSMBIOS.SerialNumber, 100, 10, 200, 20) GUICtrlCreateLabel("Asset tag:", 15,40) GUICtrlCreateInput($objSMBIOS.SMBIOSAssetTag, 100, 40, 200, 20) GUICtrlCreateLabel("Computer name:", 15,70) GUICtrlCreateInput(@ComputerName, 100, 70, 200, 20) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WendAgain, awesome :-) Any chance you know how to pull the computer domain (not logon domain)? I just found out they need that too. After that this script is done. Thanks for the copy/paste feature! This script is perfect
weaponx Posted March 28, 2008 Posted March 28, 2008 I don't know what you mean by "not logged on domain". $wmi = ObjGet("winmgmts:") $wql = "select * from win32_computersystem" $results = $wmi.execquery($wql) for $compsys in $results ConsoleWrite($compsys.domain) next
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