Page 1 of 1
Help with vbscript for changing xp key
Posted: Sat Apr 12, 2008 7:40 pm
by TimeSurfer
can anyone convert this for pb4 i have tried but im too much of a newb lol,
its supposed to allow you to change the xp product key, i get the jest of it but i have no clue how to convert this code for use as a dll.
Code: Select all
' WMI Script - ChangeVLKey.vbs
'
' This script changes the product key on the computer
'
'***************************************************************************
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
Posted: Sat Apr 12, 2008 7:45 pm
by TimeSurfer
here's another vbscript i came across that does same thing so thought id post it too as i dont know which one i would need if i wanted to use it as a pb dll [once converted of course] and i still have no clue on how to convert it.
Code: Select all
Option Explicit
'////////////////////////////////////////////////////////////////////////////
'Windows Product Key and Activation Reset
'Portions of this script were modified from the
'Microsoft provided script which can be found at:
'http://support.microsoft.com/Default.aspx?kbid=328874
'////////////////////////////////////////////////////////////////////////////
Const CSDKey = "HKLM\SYSTEM\CurrentControlSet\Control\Windows\CSDVersion"
Const WinVerKey = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName"
Dim objShell
Dim intActions, vRetVal, strProdKey
'Create Objects
Set objShell = CreateObject("WScript.Shell")
'Set Run-Time Environment
intActions = 0
'Verify Platform
vRetVal = GetData(WinVerKey, "Unknown")
If vRetVal <> "Microsoft Windows XP" Then CleanEnv -1
'Verify new Product Key
If WScript.Arguments.Count = 0 Then
strProdKey = InputBox("Enter New Product Key:" & vbCr & _
"(like: ABCDE-FGHIJ-KLMNO-PRSTU-WYQZX)", "Change Product Key")
If Trim(strProdKey) = "" Then CleanEnv -2
Else
strProdKey = WScript.Arguments.Item(0)
End If
strProdKey = UCase(Trim(Replace(strProdKey, "-", "")))
If Len(strProdKey) <> 25 Then CleanEnv -2
'Verify Service Pack Level
vRetVal = GetData(CSDKey, -1)
'Reset Product Key
'Delete SP1 and greater registry information
If vRetVal => 256 Then DelOOBEKey
'Use WMI to reactivate
SetProductKey
'Exit
CleanEnv intActions
'----------------------------------------------------------
Sub CleanEnv(intExitCode)
On Error Resume Next
Set objShell = Nothing
WScript.Quit intExitCode
End Sub
Function GetData(strRegKey, vDefault)
Dim vReturn
On Error Resume Next
vReturn = objShell.RegRead(strRegKey)
If Err.number <> 0 Then
Err.Clear
GetData = vDefault
Else
GetData = vReturn
End If
End Function
Sub DelOOBEKey()
On Error Resume Next
objShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WPAEvents\OOBETimer"
If Err.number <> 0 Then Err.Clear
End Sub
Sub SetProductKey()
Dim objProd, vResult
For Each objProd In GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf ("win32_WindowsProductActivation")
vResult = objProd.SetProductKey(strProdKey)
If Err.Number <> 0 Then
intActions = Err.Number
Err.Clear
End If
Next
Set objProd = Nothing
End Sub
'*************************************************
'Return Values:
'
' -1 = Incorrect Windows Version
' -2 = Incorrect Product Key or No Product Key supplied
' 0 = Script completed as expected
' ## = WMI Error. Task failed.
'*************************************************
Posted: Sat Apr 12, 2008 8:52 pm
by SFSxOI
This should be easy for you to convert. A quick search of the forums for registry related API's stuff should do the trick for you. All this VB script basically does is change a registry entry and delete a registry entry. A simple string input gadget to enter the key, a write to the registry of that key, and delete one other key and your done, maybe 20 to 30 lines (just guessing) at the most if you get a little fancy with a window of some sort, less without. A look at the API's at microsoft should reveal anything else you need for the registry API's.
Posted: Sat Apr 12, 2008 11:35 pm
by Fluid Byte
VB Script? Key changer? Am I the only one finding this a little suspicious?
Posted: Sat Apr 12, 2008 11:40 pm
by Sparkie
Posted: Sun Apr 13, 2008 3:11 am
by Rook Zimbabwe
Any calls by a n00b for hacking scripts are always to be viewed with the evil eye... but then again, I taught Middle School for 10 years... I know that most teenagers have no moral compass.
Posted: Sun Apr 13, 2008 4:18 am
by TimeSurfer
you 2 are helarious.... anyways the above script is provided on msdfn fyi.
Posted: Sun Apr 13, 2008 4:22 am
by TimeSurfer
thanks SFSxOI,

will check them out now.
Posted: Sun Apr 13, 2008 4:38 am
by Fluid Byte
TimeSurfer wrote:you 2 are helarious.... anyways the above script is provided on msdfn fyi.
Apart from the fact that it's
hilarious and not
helarious it's actually rather sad. Unfortunately we see this kinda requests pretty often and from 100 people it's about 90 who want to accomplish something harmful. In most cases it's far away from being a matter of course like you express it. Wich still proves not much, respectively nothing.

Posted: Sun Apr 13, 2008 4:55 am
by JCV
I dont trust any vb script.
Here in my cafe I stop vb script from executing. I get headache in removing macro viruses.
