Jump to content

Serial # from BIOS?


TSO
 Share

Recommended Posts

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)
Link to comment
Share on other sites

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)
Next

See here for some other WMI tricks:

http://msdn2.microsoft.com/en-us/library/a...587(VS.85).aspx

Edited by weaponx
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

Yeah, 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.
Link to comment
Share on other sites

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 by TSO
Link to comment
Share on other sites

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 by TSO
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

There are macros for hostname...

@ComputerName

@UserName

@IPAddress1

etc...

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.
Link to comment
Share on other sites

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 by TSO
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)
Link to comment
Share on other sites

$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 by weaponx
Link to comment
Share on other sites

$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
Again, 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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...