一、备份Win7激活文件:
①右击“备份Win7激活文件.bat”-“以管理员身份运行”-即在当前文件夹得到两个文件:pkeyconfig.xrm-ms 和 tokens.dat
②用“Windows序列号查看器.vbs”来查看激活时所用的序列号,并记录下来
二、恢复Win7激活文件:(计算机名要与原来一致)
①首先右击编辑“恢复Win7激活文件.bat”,将其中的序列号改为当时激活时所用的序列号
②接下来右击“恢复Win7激活文件.bat”-“以管理员身份运行”(这个批处理要与上述两个文件放在同一文件夹)
查看自己的Win7产品信息方法:
右击“命令提示符”“以管理员身份运行”,然后输入以下命令查看:
slmgr.vbs -dli
显示:操作系统版本、部分产品密钥、许可证状态
slmgr.vbs -dlv
显示:操作系统版本、激活ID、安装ID、各种证书地址、部分产品密钥、许可证状态等
slmgr.vbs -xpr
显示:是否永久激活
“备份Win7激活文件.bat”文件内容:
@echo off copy %windir%\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms copy %windir%\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\tokens.dat pause exit
“Windows序列号查看器.vbs”文件内容:(以ANSI编码保存为.vbs文件运行即可)
'==========================================================================
' Windows序列号查看器
'==========================================================================
Option Explicit
ON ERROR RESUME NEXT
Dim g_strComputer, g_objRegistry, g_EchoString
g_strComputer = "."
g_EchoString = ""
private const L_MsgErrorPKey = "没有安装Windows序列号, 以下为注册表残留信息。"
private const L_MsgErrorRegPKey = "没有在注册表中找到Windows序列号。"
private const L_MsgErrorRegPID = "没有在注册表中找到Windows产品ID。"
Private const L_MsgProductName = "系统: "
private const L_MsgProductDesc = "系统描述: "
private const L_MsgVersion = "版本号: "
Private Const L_MsgServicePack = "补丁包: "
Private Const L_MsgBuild = "编译代号: "
private const L_MsgProductKey = "序列号: "
private const L_MsgProductId = "产品ID: "
private const HKEY_LOCAL_MACHINE = &H80000002
Private Const WindowsNTInfoPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
'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
LineOut ""
LineOut "本程序用来查看Windows的序列号。"
LineOut "适用于绝大多数Windows系统,包括 XP/Vista/Win7 系列等。"
End Sub
Private Sub ShowInfo
Dim Ans, objFSO, outFile, strSave
Set objFSO = CreateObject("Scripting.FileSystemObject")
strSave = vbNewLine & "-----------------------------------------------------------" & vbNewLine & g_EchoString
strSave = strSave & vbNewLine & "------ " & Now() & " " & "由Windows序列号查看器保存" & " ------" & vbNewLine
LineOut ""
LineOut ""
LineOut "是否保存以上信息到文本文件 WindowsKey.txt ?"
Ans = MsgBox(g_EchoString, 4, "Windows序列号查看器")
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
“恢复Win7激活文件.bat”文件内容:
@echo off net stop sppsvc /y takeown /f "%WinDir%\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms" cacls "%WinDir%\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\tokens.dat" /e /g everyone:f cacls "%WinDir%\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms" /e /g everyone:f ren "%WinDir%\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\tokens.dat" "tokens.bak" ren "%WinDir%\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms" "pkeyconfig.bak" copy tokens.dat "%WinDir%\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\" copy pkeyconfig.xrm-ms "%WinDir%\System32\spp\tokens\pkeyconfig\" del "%WinDir%\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\tokens.bak" del "%WinDir%\System32\spp\tokens\pkeyconfig\pkeyconfig.bak" net start sppsvc cscript %windir%\system32\slmgr.vbs -ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX cscript %windir%\system32\slmgr.vbs -ato pause exit