Jump to content

Always need to RegDelete() both 64-bit -AND- 32-bit reg keys?


Go to solution Solved by TXTechie,

Recommended Posts

Under a 64-bit OS, do I always have to call RegDelete() with both the 64-bit reg path and the regular reg path if I want to delete a reg key or value?

I've been insulted here : for writing more than a dozen or so words in these posts, but I don't know any other way to explain myself, so here I go again (please be kind):

I've been struggling with the fact that the scripts I've recently written to delete some registry keys on a 64-bit Windows 7 Pro system don't end up actually deleting the keys in question.  In these scripts, I've always made sure to suffix the reg root key with "64", as emphasized in the RegDelete() help file.  For instance, to delete a key starting with "HKU", I've made sure the reg path starts with "HKU64".

I scrupulously check the return codes after every function, and certainly did so with the RegDelete() calls, but while there was never any error, the keys in question were always still there when I examined them using my 64-bit registry editor (Registrar Registry Manager 64-bit), using the standard key paths!

After repeatedly failing to actually delete the keys in question, I modified the scripts to call RegDelete() with both "HKU64..." -and- "HKU...", and lo and behold, it worked!  The keys were actually gone.

Questions: (1): Is this something everyone already knows?  If so, where is it explained?

(2): Is it always true under a 64-bit OS that one must always delete both sets of keys?  Or is it necessary sometimes but not others?

Please help me understand this.

(Misc Info: I have UAC disabled, and I always run with Administrator privelege.  All the reg keys and values I wish to delete are in the "HKU/HKU64" or "HKCU/HKCU64" trees.)

Thanks!

 

Link to comment
Share on other sites

If the key/value in question is in both hives (64-bit and 32-bit), then yes you have to call RegDelete twice. Are you running 64-bit AutoIt or 32-bit? What key/value are you trying to delete?

 

Thanks very much for your helpful reply, zorphnog !

I'm using the 64-bit version of AutoIt.

Although there are several different keys/values I want to delete (depending on the script), a typical key I want to delete starts at this path: HKEY_CURRENT_USERSoftwareNeoSoftToolsSystem ManagerCommonFileInfo

But all of the keys/values I want to delete are either in the HKU or the HKCU paths.

Now here's an additional question, if you don't mind:  In the help file for RegDelete(), there's the following statement: "When running on 64-bit Windows if you want to delete a key or value specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64."

Could you please explain how I can tell whether a given registry entry is "specific to the 64-bit environment"? 

 

Thanks again for your help!

Link to comment
Share on other sites

  • Solution

Mbee,

Basically, if 64-bit software (or a 64-bit process) is what wrote the registry keys/values, then they'll be under the default HKLM, HKCU, HKU hives on a 64-bit Windows OS. If, however, it was 32-bit software (or a 32-bit process) that wrote the registry keys/values, then they'll be under the WOW64 (32-bit) sub-keys (i.e. HKLMSOFTWAREWow6432Node; HKCUSoftwareWow6432Node; etc.) on a 64-bit Windows OS. In my experience, you'll see this more under the HKLM hive than under the user-level hives (HKCU & HKU).

And if you don't know what bitness created/wrote to the registry, you'll just have to look in both places to see where they are located. Worst case, you can always code for both as a catch-all. However, I usually find out where they are actually located and code accordingly.

You can read more about this here:

 

And, you can find a comprehensive reference of what all is involved (including redirections) here:

 

Link to comment
Share on other sites

Wow(64 ;)) -- What great and extremely helpful information!

Huge thanks to zorphnog, jguinch, Unc3nZureD, and especially TXTechie!

I'll close by briefly pointing out the source of my confusion that led to my OP.  If you look at these two posts (from 2008):

by Emiel Wieldraaijer, and by GEOSoft,

... you'll see some code that, if running on a 64-bit OS, would completely modify ALL registry key root strings to add the '64' suffix.  That led me to do the same thing in my own code.  I now know from the info you four provided me here that that approach was wrong from the start.

Thanks again for setting me straight!

 

Link to comment
Share on other sites

  • 1 year later...

I am having the same issue. It's doing my head in. lol When I run the below it deletes the 64 bit entry but not the 32 bit entry. 

I am running Windows 7  64 bit

 


Dim $root = "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC"
Dim $root64 = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC"
;Local $aArrayOfData = _Security__LookupAccountName(@UserName)

If @OSArch="X86" Then
   RegDelete ("HKLM\SOFTWARE\ODBC\ODBC.INI")
ElseIf @OSArch="X64" Then
    RegDelete ("HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI")
    RegDelete ("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI")
EndIf

Link to comment
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
 Share

×
×
  • Create New...