Search code examples
vb.netregistry32bit-64bitwow64

Writing to HKLM when running in command line mode


I have a program which writes values to the registry.

I has a GUI mode and a command line mode. The program writes to HKLM perfectly when running in GUI mode (x86 build config)

However when i run my program in command mode, the values are written under the wow6432 node. I have done some research and found that the wow6432 node is used to store the registry values of a 32bit application which has been run on a 64bit machine.

I wouldn't have thought that running in command line mode would change from 64bit to 32 - but it seems to be.

Not really sure where to go from here, hopefully someone can point me in the right direction.

Build Config


Solution

  • After a bit more research - i found that when running in command line mode the registry re director was redirecting to the wow6432 node.

    To bypass this, i used :

    RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)
    

    This then opens the 64 bit view directly, and allows HKLM to be written to without being re directed to the wow6432 node.