1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| Dim ProdKey, objWMIItems, Items, result, RE, CheckChaine, test
ON ERROR RESUME NEXT
ProdKey = "12345-12345-12345-12345-12345"
ChangeKey
Sub ChangeKey
ProdKey = InputBox("Veuillez entrez la clef de Windows XP Pro MUI SP2","Test",ProdKey)
If ProdKey = "" Then
ProdKey = "Veuillez entrez une clef valide!"
ChangeKey
ElseIf ChecKey(ProdKey) Then
KeyOk
Else
ProdKey = "Format Clef invalide!"
ChangeKey
End if
End Sub
Sub KeyOk
ProdKey = Replace(ProdKey,"-","")
For Each Items In GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf ("win32_WindowsProductActivation")
result = Items.SetProductKey(ProdKey)
if err = 0 then
WScript.Echo "La clef à été changé avec succès!"
WScript.CreateObject("WScript.Shell").Run "cmd /c echo Clef Produit Windows XP Ok >> %SystemDrive%\ChangeKey.txt"
WScript.Quit
else
Err.Clear
end if
Next
End Sub
ProdKey = "Clef invalide!"
ChangeKey
Function ChecKey(chaine)
Set RE = New RegExp
RE.Pattern = "\w{5}\-\w{5}\-\w{5}\-\w{5}\-\w{5}"
set CheckChaine = RE.Execute(chaine)
If CheckChaine.Count = 0 Then
ChecKey = False
Else
ChecKey = True
End If
End Function |
Partager