唉。现在的世道。连复制脚本都复制少了。
完整脚本如下,是很久以前写的了。我都忘记得差不多了,还给你们翻出来。
有时间我整理,更新一下吧。
#include <GUIConstants.au3>
$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colComputers = $objWMIService.ExecQuery("Select * from win32_WindowsProductActivation")
$hgui = GUICreate("Windows XP/2003 序列号更换工具", 300, 150)
GuiSetIcon("shell32.dll",162, $hgui)
Dim $Setkey = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductID")
GUICtrlCreateLabel("系统序列号:更换序号请按照以下格式输入", 20, 10, 300, 20)
GUICtrlSetColor(-1,0xff0000)
$Key = GUICtrlCreateInput("",20, 30,230, 25)
GUICtrlSetData($key, DecodeProductKey($Setkey))
$readbutton = GUICtrlCreateButton("修改", 20, 80, 100, 25)
$exitbutton = GUICtrlCreateButton("退出", 150, 80, 100, 25)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $readbutton
$readkey = GUICtrlRead($Key)
If $readkey = "" then
MsgBox(16,"错误","你确定你输入的序列号没错吗?")
Else
$Setkey=StringReplace($readkey,"-","")
;MsgBox(0,"sdlkfj",$Setkey)
for $obj In $colComputers
$Obj.SetProductKey ($Setkey)
if @error = 0 then
MsgBox(64,"恭喜!!!","您的 Windows CD-KEY 修改成功。请检查系统属性。")
Endif
if @error <> 0 then
MsgBox(16,"失败","修改失败!请检查输入的 CD-KEY 是否与当前 Windows 版本相匹配。")
Endif
Next
Endif
Case $msg = $GUI_EVENT_CLOSE Or $msg = $exitbutton
Exit
EndSelect
WEnd
Func DecodeProductKey($BinaryDPID)
Local $bKey[15]
Local $sKey[29]
Local $Digits[24]
Local $Value = 0
Local $hi = 0
Local $n = 0
Local $i = 0
Local $dlen = 29
Local $slen = 15
Local $Result
$Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "")
$BinaryDPID = StringMid($BinaryDPID, 105, 30)
For $i = 1 To 29 Step 2
$bKey[Int($i / 2) ] = Dec(StringMid($BinaryDPID, $i, 2))
Next
For $i = $dlen - 1 To 0 Step - 1
If Mod(($i + 1), 6) = 0 Then
$sKey[$i] = "-"
Else
$hi = 0
For $n = $slen - 1 To 0 Step - 1
$Value = BitOR(BitShift($hi, -8), $bKey[$n])
$bKey[$n] = Int($Value / 24)
$hi = Mod($Value, 24)
Next
$sKey[$i] = $Digits[$hi + 1]
EndIf
Next
For $i = 0 To 28
$Result = $Result & $sKey[$i]
Next
Return $Result
EndFunc
|