Jump to content
Sign in to follow this  

Unable to change registry key properly

Recommended Posts



I have encountered a weird situation where the program I have written is not writing to the registry properly. The RegWrite calls from a variable that is generated from an input box, but when it writes it to the registry, instead of the text that is in the variable, a number 4 appears!

I have some extra code floating around in there. Change the RegWrite variable to file2 and the correct registry information appears (based on what file2 is hard-coded to have in it).

So here are the results:

1. If using the input field, the value written is "4". The msgbox displays "serialnumber"

2. If using the hardcoded var, the value written is "serialnumber". The msgbox displays whatever you typed in the field.

Is there something I am missing here? I cannot locate where this 4 is coming from.

; Nero 7 Essentials Suite 2 Serial Number Changer
; Coded by Philip J Tomczak
; contact info@tripredacus.net, ptomczak@gled.com
; sources: msfn.org, autoitscript.com
#include <GUIConstants.au3>
; main program
$user = @UserName
$mainwindow = GuiCreate("Nero Serial Changer", 320, 120)
$Label_text = GuiCtrlCreateLabel("Input Serial Number with Hyphens",10,5,300,20)
$file = GUICtrlCreateInput ( "", 10,  20, 300, 20)
$file2 = "serialnumber"
$btn = GUICtrlCreateButton ("Ok", 40,  75, 60, 20)
GUISetState () 

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
           Case $msg = $btn

RegDelete( "HKEY_LOCAL_MACHINE\SOFTWARE\ahead\Installation\Families\Nero 7\Info")
RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\ahead\Installation\Families\Nero 7\Info" , "CDNR" , "REG_SZ" , "12938" )
RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\ahead\Installation\Families\Nero 7\Info" , "Company" , "REG_SZ" , "" )
RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\ahead\Installation\Families\Nero 7\Info" , "EulaAccepted" , "REG_SZ" , "1" )
RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\ahead\Installation\Families\Nero 7\Info" , "MissingFilesState" , "REG_SZ" , "0" )
RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\ahead\Installation\Families\Nero 7\Info" , "Serial7_1185911858" , "REG_SZ" , $file )
RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\ahead\Installation\Families\Nero 7\Info" , "User" , "REG_SZ" , $user )
RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\ahead\Installation\Families\Nero 7\Info" , "Version" , "REG_SZ" , "" )

MsgBox (4096, "New Serial Number", GUICtrlRead($file))

; serialnumber

NOTE: any text in the above code with the word "serialnumber" has an actual serial number in my code. The commented one at the bottom was a copy/paste line for testing.

Edited by Tripredacus

Share this post

Link to post
Share on other sites

The syntax for this line is wrong:

RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\ahead\Installation\Families\Nero 7\Info" , "Serial7_1185911858" , "REG_SZ" , $file )

should be

RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\ahead\Installation\Families\Nero 7\Info" , "Serial7_1185911858" , "REG_SZ" , GuiCtrlRead($file) )

BTW..... 4 = ControlID of inputbox

Edited by weaponx

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.