01.vbs 使用功能:补丁包、版本号、编译代号、序列号、产品ID、(该代码能实现统一显示、自动保存为.txt的功能)
系统版本(这个显示不够完整,希望用02.vbs里的替换)
比如:01.vbs只显示“Microsoft Windows XP”,但02.vbs显示的是“Microsoft Windows XP Professional”
02.vbs 使用功能:IP地址、系统版本(这个显示更详细)、IE版本
01.vbs内容:
Option Explicit
ON ERROR RESUME NEXT
Dim g_strComputer, g_objRegistry, g_EchoString
'If this is the local computer, set everything immediately
If g_strComputer = "." Then
Set g_objRegistry = GetObject("winmgmts:\\" & g_strComputer & "\root\default:StdRegProv")
End If
Call ExecCommand()
Call ShowInfo()
ExitScript 0
Private Sub ExecCommand
Dim productKeyFound
Dim strProductKey, strProductId, strProductVersion, strTmp
Dim bRegPKeyFound, bRegPIDFound ' value exists in registry
'Retrieve information from registry
bRegPKeyFound = False : bRegPIDFound = False : productKeyFound = False
g_objRegistry.GetBinaryValue HKEY_LOCAL_MACHINE, WindowsNTInfoPath, "DigitalProductId", strTmp
If Not IsNull(strTmp) Then
strProductKey=GetKey(strTmp)
bRegPKeyFound = True
End If
g_objRegistry.GetStringValue HKEY_LOCAL_MACHINE, WindowsNTInfoPath, "ProductId", strTmp
If Not IsNull(strTmp) Then
strProductId = strTmp
bRegPIDFound = True
End If
LineOut ""
g_objRegistry.GetStringValue HKEY_LOCAL_MACHINE, WindowsNTInfoPath, "ProductName", strTmp
LineOut GetResource("L_MsgProductName") & strTmp
g_objRegistry.GetStringValue HKEY_LOCAL_MACHINE, WindowsNTInfoPath, "CSDVersion", strTmp
If Not IsNull(strTmp) Then
LineOut GetResource("L_MsgServicePack") & strTmp
End If
g_objRegistry.GetStringValue HKEY_LOCAL_MACHINE, WindowsNTInfoPath, "CurrentVersion", strProductVersion
g_objRegistry.GetStringValue HKEY_LOCAL_MACHINE, WindowsNTInfoPath, "CurrentBuildNumber", strTmp
strProductVersion=strProductVersion & "." & strTmp
LineOut GetResource("L_MsgVersion") & strProductVersion
g_objRegistry.GetStringValue HKEY_LOCAL_MACHINE, WindowsNTInfoPath, "BuildLabEx", strTmp
If IsNull(strTmp) Then
g_objRegistry.GetStringValue HKEY_LOCAL_MACHINE, WindowsNTInfoPath, "BuildLab", strTmp
End If
LineOut GetResource("L_MsgBuild") & strTmp
productKeyFound = True
LineOut ""
If productKeyFound <> True Then
LineOut GetResource("L_MsgErrorPKey")
End If
If bRegPKeyFound Then
LineOut GetResource("L_MsgProductKey") & strProductKey
Else
LineOut GetResource("L_MsgErrorRegPKey")
End If
If bRegPIDFound Then
LineOut GetResource("L_MsgProductId") & strProductId
Else
LineOut GetResource("L_MsgErrorRegPID")
End If
g_EchoString = ""
If Ans = vbYes Then
Set outFile = objFSO.OpenTextFile(".\WindowsKey.txt", 8 , True) ' append to file
outFile.WriteLine strSave
outFile.Close
LineOut "已经保存到文件 WindowsKey.txt !"
End If
End Sub
Private Function GetKey(rpk) 'Decode the product key
Const rpkOffset=52
Dim dwAccumulator, szPossibleChars, szProductKey
dim i,j
i=28 : szPossibleChars="BCDFGHJKMPQRTVWXY2346789"
Do 'Rep1
dwAccumulator=0 : j=14
Do
dwAccumulator=dwAccumulator*256
dwAccumulator=rpk(j+rpkOffset)+dwAccumulator
rpk(j+rpkOffset)=(dwAccumulator\24) and 255
dwAccumulator=dwAccumulator Mod 24
j=j-1
Loop While j>=0
i=i-1 : szProductKey=mid(szPossibleChars,dwAccumulator+1,1)&szProductKey
if (((29-i) Mod 6)=0) and (i<>-1) then
i=i-1 : szProductKey="-"&szProductKey
end if
Loop While i>=0 'Goto Rep1
GetKey=szProductKey
End Function
' Get the resource string with the given name using the built-in default.
Private Function GetResource(name)
GetResource = Eval(name)
End Function
Private Sub ExitScript(retval)
if (g_EchoString <> "") Then
MsgBox g_EchoString, 0, "Windows 序列号查看器"
End If
WScript.Quit retval
End Sub
' Functions Without Change Below
Private Sub LineOut(str)
g_EchoString = g_EchoString & str & vbNewLine
End Sub
02.vbs内容:
Function GetLocalIP(ComputerName)
Dim objWMIService,colItems,objItem,objAddress
Set objWMIService = GetObject("winmgmts://" & ComputerName & "/root/cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
For Each objAddress in objItem.IPAddress
If objAddress <> "" then
GetIPMAC = objAddress
Exit For
End If
Next
Exit For
Next
a=msgbox(GetIPMAC)
End Function
GetLocalIP(".")
Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
for each objOperatingSystem in colOperatingSystems
msgbox "SO version: "& objOperatingSystem.Caption
next
Set objwmiserviceIE=GetObject("winmgmts:\\" & strComputer & "\root\cimv2\Applications\MicrosoftIE")
Set colIESettings=objwmiserviceIE.execquery("select * from MicrosoftIE_Summary")
For Each strIESetting In colIESettings
MsgBox "IE version: "&strIESetting.version
MsgBox "产品 ID: "&strIESetting.productID
next