How do I read startup items from registry on 64 bit Windows?
64-bit, registry, vb.net, windows
Solution
Your process is a 32 bit process and so, on a 64 bit OS, the registry redirector comes into play. The `HKLM\Software` key is redirected and there are two views of it, a 32 bit view that your process is finding, and a 64 bit view.
It is true that if you run a 64 bit process, you will see the 64 bit view of the registry. However, that is not the full story. Windows processes `CurrentVersion\Run` entries from both 32 and 64 bit views of the registry. So, if you just switched to an x64 or AnyCPU process you would then be missing the autoruns stored in the 32 bit registry view.
So, since your goal is to list all the autoruns, you will need to read both 32 and 64 bit views of the registry. You can do that using the `RegistryView` enumeration that was introduced in .net 4. This allows a 32 bit process to access the 64 bit view of the registry. And indeed it allows a 64 bit process to access the 32 bit view of the registry.
If you want a process that runs on both 32 bit and 64 bit systems you will need to target either x86 or AnyCPU. And then use `RegistryView` to read both views of the registry if you detect that you are running on a 64 bit system.
Problem
I am currently trying to get a list of all autoruns, but I am struggling on a 64-bit system. When I use: ``` My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", False) ``` It shows me entries from: ``` My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run", False) ``` Anyone know why and/or how to fix this? I should also state that the items in HKLM\..\Run are different to those in HKLM\..\Wow6432Node..\Run.