y si paramos y reiniciamos el explorer.exe no va?
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes MenúCitar
Option Explicit
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Const REG_BINARY = 3
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const REG_SZ = 1
' ruta del registro donde Windows guarda la clave (codificada) y la versión
Private Const RUTA_REGISTRO = "SOFTWARE\MICROSOFT\Windows NT\CurrentVersion"
Private Sub Command1_Click()
On Error GoTo mal
Dim VOL_PROD_KEY As String
'El valor de la key se le pasa como parámetro
VOL_PROD_KEY = Text1.Text & Text2.Text & Text3.Text & Text4.Text & Text5.Text
Dim Obj As Object
Dim result As Variant
VOL_PROD_KEY = UCase(VOL_PROD_KEY)
'Se cambian las letras/numeros a mayusculas
VOL_PROD_KEY = Replace(VOL_PROD_KEY, "-", "") 'remove hyphens if any
'Se reemplazan los guiones "altos"
For Each Obj In GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("win32_WindowsProductActivation")
'Se utiliza WMI para acceder a la clase correspondiente
result = Obj.SetProductKey(VOL_PROD_KEY)
'Se cambia la key de win y se almacena el resultado en una variable
Next
Exit Sub
mal:
MsgBox "key ingrasada incorrecta"
End Sub
Private Function SacarClave() As String
Dim bID(164) As Byte, bKey(14) As Byte, bAsc(24) As Byte
Dim lBit As Long, hKey As Long
If RegOpenKey(HKEY_LOCAL_MACHINE, RUTA_REGISTRO, hKey) = 0 Then
If RegQueryValueEx(hKey, "DigitalProductId", 0&, REG_BINARY, bID(0), 164) = 0 Then
For lBit = 52 To 66
bKey(lBit - 52) = bID(lBit)
Next lBit
Else
MsgBox "No se puede leer la clave."
SacarClave = ""
Exit Function
End If
Else
MsgBox "No se puede acceder al registro."
SacarClave = ""
Exit Function
End If
'Descodificar la clave
bAsc(0) = Asc("B"): bAsc(1) = Asc("C"): bAsc(2) = Asc("D")
bAsc(3) = Asc("F"): bAsc(4) = Asc("G"): bAsc(5) = Asc("H")
bAsc(6) = Asc("J"): bAsc(7) = Asc("K"): bAsc(8) = Asc("M")
bAsc(9) = Asc("P"): bAsc(10) = Asc("Q"): bAsc(11) = Asc("R")
bAsc(12) = Asc("T"): bAsc(13) = Asc("V"): bAsc(14) = Asc("W")
bAsc(15) = Asc("X"): bAsc(16) = Asc("Y"): bAsc(17) = Asc("2")
bAsc(18) = Asc("3"): bAsc(19) = Asc("4"): bAsc(20) = Asc("6")
bAsc(21) = Asc("7"): bAsc(22) = Asc("8"): bAsc(23) = Asc("9")
Dim i As Integer, j As Integer, sClave As String
For lBit = 24 To 0 Step -1
i = 0
For j = 14 To 0 Step -1
i = i * 256 Xor bKey(j)
bKey(j) = Int(i / 24)
i = i Mod 24
Next j
sClave = Chr(bAsc(i)) & sClave
If lBit Mod 5 = 0 And lBit <> 0 Then sClave = "-" & sClave
Next lBit
SacarClave = sClave
Label1.Caption = SacarClave
End Function
Private Function VerVersion()
Dim lRet As Long
RegOpenKey HKEY_LOCAL_MACHINE, RUTA_REGISTRO, lRet
VerVersion = SacarValorRegistro(lRet, "ProductName")
RegCloseKey lRet
RegOpenKey HKEY_LOCAL_MACHINE, RUTA_REGISTRO, lRet
VerVersion = VerVersion & " - " & SacarValorRegistro(lRet, "CSDVersion")
RegCloseKey lRet
Label2.Caption = "Versión: " & VerVersion
End Function
Function SacarValorRegistro(ByVal HKLM As Long, ByVal sValor As String) As String
Dim lRet As Long, lInfoValor As Long
Dim lLen As Long, sBuffer As String
lRet = RegQueryValueEx(HKLM, sValor, 0, lInfoValor, ByVal 0, lLen)
If lRet = 0 Then
If lInfoValor = REG_SZ Then
sBuffer = String(lLen, Chr$(0))
lRet = RegQueryValueEx(HKLM, sValor, 0, 0, ByVal sBuffer, lLen)
If lRet = 0 Then
SacarValorRegistro = Left$(sBuffer, InStr(1, sBuffer, Chr$(0)) - 1)
End If
ElseIf lInfoValor = REG_BINARY Then
Dim strData As Integer
lRet = RegQueryValueEx(HKLM, sValor, 0, 0, strData, lLen)
If lRet = 0 Then SacarValorRegistro = strData
End If
End If
End Function
Private Sub Form_Load()
Call SacarClave
Call VerVersion
End Sub
Private Sub Timer1_Timer()
Call SacarClave
End Sub
Private Sub Text1_Change()
Dim i As Integer
Dim claves() As String
If Len(Text1.Text) = 29 Then
claves = Split(Text1.Text, "-")
For i = 1 To 5
Controls("Text" & i).Text = claves(i - 1)
Next
End If
If Len(Text1.Text) = 5 Then
Text2.SetFocus
End If
End Sub
Private Sub Text2_Change()
If Len(Text2.Text) = Text2.MaxLength Then
Text3.SetFocus
End If
End Sub
Private Sub Text3_Change()
If Len(Text3.Text) = Text3.MaxLength Then
Text4.SetFocus
End If
End Sub
Private Sub Text4_Change()
If Len(Text4.Text) = Text4.MaxLength Then
Text5.SetFocus
End If
End Sub
CitarPrivate Sub TextBox1_Change()
If Len(TextBox1.Text) = 29 Then
claves = Split(TextBox1.Text, "-")
For i = 1 To 5
Controls("TextBox" & i).Text = claves(i - 1)
Next
End If
End Sub
Citary debe ser legal porque hasta en la pagina de microsoft hay explicadas formas de como cambiar la clave
Citarel valor no es opcional
CitarCitar
ON ERROR RESUME NEXT
if Wscript.arguments.count<1 then
Wscript.echo "Script can't run without VolumeProductKey argument"
Wscript.echo "Correct usage: Cscript ChangeVLKey.vbs ABCDE-FGHIJ-KLMNO-PRSTU-WYQZX"
Wscript.quit
end if
Dim VOL_PROD_KEY
VOL_PROD_KEY = Wscript.arguments.Item(0)
VOL_PROD_KEY = Replace(VOL_PROD_KEY,"-","") 'remove hyphens if any
for each Obj in GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf ("win32_WindowsProductActivation")
result = Obj.SetProductKey (VOL_PROD_KEY)
if err <> 0 then
WScript.Echo Err.Description, "0x" & Hex(Err.Number)
Err.Clear
end if
Next
y se usa asi
Citar
1. guardar el scrit en c:\changevlkeysp1.vbs
2. Haga clic en Inicio y, a continuación, haga clic en Ejecutar.
3. En el cuadro Abrir, escriba el comando siguiente, donde AB123-123AB-AB123-123AB-AB123 es la nueva clave del producto que desea utilizar y haga clic en Aceptar:
c:\changevlkeysp1.vbs ab123-123ab-ab123-123ab-ab123