Aug
28
How To Retrieve The UUID/GUID From A Computer?
Monday, 28. August 2006 11:40
The VBScript function below, GetUUID, shows how to retrieve the UUID/GUID from a computer.
' Test it
WScript.Echo GetUUID(".")
Function GetUUID(strComputer)
Dim objWmi, colItems, objItem, strUUID, blnValidUUID
Set objWmi = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWmi.ExecQuery("Select * from Win32_ComputerSystemProduct")
strUUID = ""
blnValidUUID = False
For Each objItem in colItems
strUUID = objItem.UUID
If Not IsEmpty(strUUID) OR Not IsNull(strUUID) Then
If (strUUID <> "00000000-0000-0000-0000-000000000000") AND _
(strUUID <> "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF") Then
blnValidUUID = True
Exit For
End If
End If
Next
Set objWmi = Nothing
If Not blnValidUUID Then
Set colItems = GetObject("winmgmts:" & strComputer & "\root\cimv2").InstancesOf("Win32_NetworkAdapter")
For Each objItem In colItems
If (objItem.AdapterType = "Ethernet 802.3") Then
If (objItem.Description <> "Packet Scheduler Miniport") Then
strUUID = "00000000-0000-0000-0000-" & Replace(objItem.MACAddress, ":", "")
Exit For
End If
End If
Next
Set NicSet = Nothing
End If
GetUUID = strUUID
End Function
Category:Scripting, VBScript | Comment (0) | Author: Frank-Peter