Skip to content

Instantly share code, notes, and snippets.

@robot56
Created February 22, 2014 20:55
Show Gist options
  • Save robot56/9162282 to your computer and use it in GitHub Desktop.
Save robot56/9162282 to your computer and use it in GitHub Desktop.
Serial Checker
'----------------------------------------------------
' Serial Checker v1 by Extreme. '
'----------------------------------------------------
' Will obtain the Serial number for specified '
' machine. '
'----------------------------------------------------
' No error reporing on VBS..
On Error Resume Next
' Get the name of the PC via the current network
Set objNetwork = WScript.CreateObject("WScript.Network")
ComputerName = objNetwork.ComputerName
' In some cases this may not detect the right device and give you the wrong serial.. in that case, you can specify the name
prompt = Msgbox("I detected that you are running on " & ComputerName & "?", vbYesNo, "Serial Finder")
' If "Yes", then go ahead and get the serial
If prompt = vbYes Then
' Query winmgmts
winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//" & ComputerName & ""
Set SNSet = GetObject( winmgmt1 ).InstancesOf ("Win32_BIOS")
for each SN in SNSet
inp = InputBox("The serial number for the specified computer is: ", "Serial Finder",SN.SerialNumber)
Next
' Else prompt for PC NAME
Else
qComputerName = InputBox("Enter the name of the computer you wish to query")
winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//" & qComputerName & ""
Set SNSet = GetObject( winmgmt1 ).InstancesOf ("Win32_BIOS")
for each SN in SNSet
' If serial is invalid, quit.
If SN.SerialNumber = "" Then
c = Msgbox("Failed! Could not get information on '" & qComputerName & "', please run the program again!",, "Serial Finder")
WScript.Quit 1
End if
inp = InputBox("The serial number for the specified computer is: ", "Serial Finder", SN.SerialNumber)
Next
End If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment