WMI更换WINDOWS序列号(IE7安装时的"序列号破解"方式中学到的东西)
2007-03-14 11:33
871 查看
引用WMI,添加一个TEXTBOX,一个COMMAND,以下是代码,成品在下载区
Option Explicit
Dim objSWbemLocator As SWbemLocator
Dim objSWbemServices As SWbemServices
Dim objSWbemObjectSet As SWbemObjectSet
Dim objSWbemObject As SWbemObject
Dim strComputer As String, strNameSpace As String, strClass As String
Private Sub Form_Load()
Text1.Font.Size = 20
Text1.Text = "MRX3F-47B9T-2487J-KWKMF-RPWBY"
strComputer = "." '计算机名,.为本机
strNameSpace = "root/cimv2" '指定命名空间为root/cimv2
strClass = "win32_WindowsProductActivation" '指定类为Win32_Service
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") '建立1个对象的引用指针
Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, strNameSpace) '连接到指定计算机、命名空间的WMI,返回一个对 对象的引用
End Sub
'刷新
Sub RefreshList()
Print "请参考MS:http://www.microsoft.com/china/windowsxp/pro/techinfo/deployment/activation/scripted.asp"
Dim mStr As String
Set objSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM " & strClass) '通过WQL查询,返回指定类的所有
For Each objSWbemObject In objSWbemObjectSet
Print mFormat("计算机名称 ", objSWbemObject.ServerName) '计算机名
Print mFormat("需要激活 ", mYesNo(objSWbemObject.ActivationRequired)) '需要激活,该值应值设为 1(表有效)。否则,设为0(表无效)。
mStr = objSWbemObject.ProductID
Print mFormat("安装序列号信息 ", mStr) '包含根据系统安装序列号得来的一个连续的9位数字,表示为“sssssssss”。除OEM外的所有系统,其格式均为:“xxxxx-sss-ssssssx-xxxxx”。而OEM的格式为:“xxxxx-OEM-xxssssx-sssss”。
Print mFormat("为OEM版本", mYesNo(mStr))
Print mFormat("剩余的评测期 ", objSWbemObject.RemainingEvaluationPeriod) '剩余的评测期,仅适用于测试版和评测版,表示剩余的天数。其最大的整数值可以是:2147483647。
Print mFormat("剩余的有效期 ", objSWbemObject.RemainingGracePeriod) '剩余的有效期
'objSWbemObject.GetInstallationID (mStr) '该方法返回PID
'Debug.Print mStr
Next
End Sub
Private Sub Form_Paint()
RefreshList '显示当前信息
End Sub
Private Function mYesNo(lng As String) As String
If InStr(1, lng, "-") Then
If InStr(1, lng, "OEM") Then mYesNo = "是" Else mYesNo = "否"
Else
If lng = 0 Then mYesNo = "否" Else mYesNo = "是"
End If
End Function
Private Function mFormat(str1 As String, str2 As String) As String
mFormat = Left(str1 & Space(20 - LenB(str1)), 20) & str2
End Function
Private Sub Command1_Click()
Dim mStr As String, mStrNew As String
Set objSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM " & strClass) '通过WQL查询,返回指定类的所有
For Each objSWbemObject In objSWbemObjectSet
objSWbemObject.GetInstallationID (mStr) '该方法返回PID
objSWbemObject.SetProductKey Replace(Text1.Text, "-", "")
objSWbemObject.GetInstallationID (mStrNew)
If mStr = mStrNew Then Me.Caption = "序列号未替换" Else Me.Caption = "序列号已经替换"
Next
End Sub
Option Explicit
Dim objSWbemLocator As SWbemLocator
Dim objSWbemServices As SWbemServices
Dim objSWbemObjectSet As SWbemObjectSet
Dim objSWbemObject As SWbemObject
Dim strComputer As String, strNameSpace As String, strClass As String
Private Sub Form_Load()
Text1.Font.Size = 20
Text1.Text = "MRX3F-47B9T-2487J-KWKMF-RPWBY"
strComputer = "." '计算机名,.为本机
strNameSpace = "root/cimv2" '指定命名空间为root/cimv2
strClass = "win32_WindowsProductActivation" '指定类为Win32_Service
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") '建立1个对象的引用指针
Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, strNameSpace) '连接到指定计算机、命名空间的WMI,返回一个对 对象的引用
End Sub
'刷新
Sub RefreshList()
Print "请参考MS:http://www.microsoft.com/china/windowsxp/pro/techinfo/deployment/activation/scripted.asp"
Dim mStr As String
Set objSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM " & strClass) '通过WQL查询,返回指定类的所有
For Each objSWbemObject In objSWbemObjectSet
Print mFormat("计算机名称 ", objSWbemObject.ServerName) '计算机名
Print mFormat("需要激活 ", mYesNo(objSWbemObject.ActivationRequired)) '需要激活,该值应值设为 1(表有效)。否则,设为0(表无效)。
mStr = objSWbemObject.ProductID
Print mFormat("安装序列号信息 ", mStr) '包含根据系统安装序列号得来的一个连续的9位数字,表示为“sssssssss”。除OEM外的所有系统,其格式均为:“xxxxx-sss-ssssssx-xxxxx”。而OEM的格式为:“xxxxx-OEM-xxssssx-sssss”。
Print mFormat("为OEM版本", mYesNo(mStr))
Print mFormat("剩余的评测期 ", objSWbemObject.RemainingEvaluationPeriod) '剩余的评测期,仅适用于测试版和评测版,表示剩余的天数。其最大的整数值可以是:2147483647。
Print mFormat("剩余的有效期 ", objSWbemObject.RemainingGracePeriod) '剩余的有效期
'objSWbemObject.GetInstallationID (mStr) '该方法返回PID
'Debug.Print mStr
Next
End Sub
Private Sub Form_Paint()
RefreshList '显示当前信息
End Sub
Private Function mYesNo(lng As String) As String
If InStr(1, lng, "-") Then
If InStr(1, lng, "OEM") Then mYesNo = "是" Else mYesNo = "否"
Else
If lng = 0 Then mYesNo = "否" Else mYesNo = "是"
End If
End Function
Private Function mFormat(str1 As String, str2 As String) As String
mFormat = Left(str1 & Space(20 - LenB(str1)), 20) & str2
End Function
Private Sub Command1_Click()
Dim mStr As String, mStrNew As String
Set objSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM " & strClass) '通过WQL查询,返回指定类的所有
For Each objSWbemObject In objSWbemObjectSet
objSWbemObject.GetInstallationID (mStr) '该方法返回PID
objSWbemObject.SetProductKey Replace(Text1.Text, "-", "")
objSWbemObject.GetInstallationID (mStrNew)
If mStr = mStrNew Then Me.Caption = "序列号未替换" Else Me.Caption = "序列号已经替换"
Next
End Sub
相关文章推荐
- 批处理安装Windows服务,提示"InstallUtil.exe"不是内部命令也不是外部命令解决方式
- ArcGis DeskTop9.3两种方式破解与安装问答
- WINDOWS 2000下使用ISAPI方式安装PHP
- Windows 8专业版(免序列号)安装体验
- 在windows 2008中安装Rational rose 2007 完美破解方法
- C#遍历系统所安装的打印机,使用WMI方式获取打印机的所有属性
- windows下jira系统的安装和破解注意事项
- windows10+anaconda2+xgboost0.6的安装,VS和MinGW两种方式
- 使用命令方式安装MongoDB指南(Windows、Linux)
- python 第三方库的安装方式(Windows、Linunx都适用)
- C#遍历系统所安装的打印机,使用WMI方式获取打印机的所有属性
- windows 64位系统安装 wmi-(ImportError: No module named)
- windows 2008 "运行安装程序时发生 -5006 0x80070002"解决
- 搭建Windows系统下php开发环境有很多种方式,比如LAMP的配置、php IDE和调试工具的选择等等。根据每个人喜好不同有很多配置方式。这里主要介绍的是利用XAMPP集成安装和配置apache、
- 一步一步安装UEFI分区方式的windows 10 企业版
- 180208—【CTF】Windows下 sqlmap 安装、配置、及快捷方式启动
- windows mac Linux下安装以及破解sublime-text-2编辑器(跟新)
- python MySQLdb在windows环境下的快速安装、问题解决方式
- Windows 安装服务 的两种方式
- windows下安装jira6.04,汉化,破解