Help with vbscript for changing xp key

Just starting out? Need help? Post your questions and find answers here.
TimeSurfer
User
User
Posts: 22
Joined: Wed Jan 23, 2008 6:58 am

Help with vbscript for changing xp key

Post 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
TimeSurfer
User
User
Posts: 22
Joined: Wed Jan 23, 2008 6:58 am

Post 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.
'*************************************************
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post 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.
Last edited by SFSxOI on Sun Apr 13, 2008 3:42 pm, edited 1 time in total.
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

VB Script? Key changer? Am I the only one finding this a little suspicious?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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.
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
TimeSurfer
User
User
Posts: 22
Joined: Wed Jan 23, 2008 6:58 am

Post by TimeSurfer »

you 2 are helarious.... anyways the above script is provided on msdfn fyi.
Last edited by TimeSurfer on Sun Apr 13, 2008 4:23 am, edited 1 time in total.
TimeSurfer
User
User
Posts: 22
Joined: Wed Jan 23, 2008 6:58 am

Post by TimeSurfer »

thanks SFSxOI, :D will check them out now.
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post 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. Image
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Post 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. :?

[Registered PB User since 2006]
[PureBasic 6.20][SpiderBasic 2.2]
[RP4 x64][Win 11 x64][Ubuntu x64]
Post Reply