Created
February 22, 2014 20:55
-
-
Save robot56/9162282 to your computer and use it in GitHub Desktop.
Serial Checker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'---------------------------------------------------- | |
' 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