How can I programmatically get the GUID of my machine?

John Savill

January 3, 2007

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. You can use the uuID attributes of the Win32_ComputerSystemProduct class to get the machine's GUID, which is read from the BIOS, as the following sample code shows:

    
strComputer ="."    
' --------------------------------------------  Set objWMIService = GetObject("winmgmts:\" & strComputer & "rootCIMV2")  Set colItems = objWMIService.ExecQuery ("SELECT * FROM Win32_ComputerSystemProduct")    
' On Error Resume Next  For Each objComputer In colItems  Wscript.Echo "uuID: " & objComputer.uuID  Next    
WScript.Quit  

For example:
D:temp>cscript getuuid.vbs

produces the following result:

uuID: 4C4C4544-0051-5810-8039-B6C04F533931

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like