Sign in to follow this  
Followers 0
beb7089

32bit complied script not working on 64bit

6 posts in this topic

My script was complied using the 32bit complier and work fine on 32 bit machines but fails to work on 64 bit.

Trying to run script on Windows 7 32 & 64bit machines.

$var = RegRead('HKLM\SOFTWARE\ODBC\ODBC.INI\VC Test', 'Server')
If @error = "0" Then
    RegWrite('HKLM\SOFTWARE\ODBC\ODBC.INI\VC Test', 'Server', 'Reg_sz', 'HQSQLDEV01')
EndIf
Exit

Share this post


Link to post
Share on other sites



Doesn't it run at all (exe crashes) or doesn't it do what you want?

Please have a look at the help file (regread function). There is some info about running AutoIt on 64-bit

Function RegRead:

... When running on 64-bit Windows if you want to read a value specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64. ..."


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

It's not that easy I stand corrected, it is that easy for at least HKLM and maybe more (just add '64' => HKLM64) :mellow:. I'm talking about Windows 7 x64 btw. For example, the 64bit version of HKEY_CLASSES_ROOT = HKEY_CLASSES_ROOT\Wow6432Node\. Same for HKEY_LOCAL_MACHINE\Software => HKEY_LOCAL_MACHINE\Software\Wow6432Node. These are, however, only used by true 64bit programs, so not by 32bit versions. If ODBC is 32 bit it would be located at the same location, and your script probably works for me (Win7 64 bit). I don't know why the compiled version wouldn't work. A script I compiled on my 64 bit machine (as 32 bit .exes) works on 32bit windows versions. It also uses RegRead, only once though. Edited by d4ni

Share this post


Link to post
Share on other sites

Doesn't it run at all (exe crashes) or doesn't it do what you want?

Please have a look at the help file (regread function). There is some info about running AutoIt on 64-bit

Function RegRead:

... When running on 64-bit Windows if you want to read a value specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64. ..."

It doesnt crash or anything. It appears to run but when you check the registry the change has not been made.

I will check out RegRead. Most everything I do is for 32bit but in this case I have about 10 64bit machines that need updating.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Do some more debugging. See if it actually reads the right value, if it executes the body of the If statement, etc. Maybe it has something to do with administrator privileges, too.

Edited by d4ni

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Do some more debugging. See if it actually reads the right value, if it executes the body of the If statement, etc. Maybe it has something to do with administrator privileges, too.

Found my issue. RegRead and RegWrite required HKLM64 or HKLM depending on the OS and it must run as Administrator. Thank you d4ni and water.

Here is my new script.

If @OSArch = "X64" Then
    $key = "HKLM64"
Else
    $key = "HKLM"
EndIf

$var = RegRead($key & '\SOFTWARE\ODBC\ODBC.INI\VC Test', 'Server')
If @error = "0" Then
    RegWrite($key & '\SOFTWARE\ODBC\ODBC.INI\VC Test', 'Server', 'Reg_sz', 'HQSQLDEV01')
EndIf
Exit
Edited by beb7089

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  
Followers 0