



It's a very easy to understand and readable approach compared to the P/Invoke solution, in my opinion.Protect yourself against online threats, like phishing and malicious websites, with real-time protection from Microsoft. All you need to do is use RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64) and you will overcome the registry redirection. I was writing a P/Invoke solution to this problem, but then I came across this. Using (RegistryKey rk = localMachineX64View.OpenSubKey(location)) RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Otherwise, if you're using an earlier version of the Framework then you need to use P/Invoke and call the function RegOpenKeyEx with the KEY_WOW64_64KEY flag from the WINAPI as described here.īut onto the solution that I used. NET 4.0 which provides a very clean solution for accessing the 64 bit registry from a 32 bit process. string MseLocation = Files\Microsoft Security Client\msseces.exe" Any assistance in discovering why would be much appreciated.įor the time being I am using the following as a substitute. If (Convert.ToString(productKey.GetValue("DisplayName")) Using (RegistryKey productKey = rk.OpenSubKey(subKey)) String location = (RegistryKey rk = (location))įoreach (string subKey in rk.GetSubKeyNames()) My Method: private static bool DoesMseExist() I'm able to see the keys of other programs in the same directory. The process that is automating the install is run as administrator.MSE is 64-bit on 64-bit machines and 32-bit on 32-bit machines (there are two different installers) Hence, the the path in the registry is always: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall.Some facts to assist those with answering: This code below is written in C#, but the problem may be applicable to other languages as well. At one point I'm checking to see if the machine (Windows 7) has Microsoft Security Essentials installed - if it doesn't then I install the program. So I have this installer script that I wrote that automatically installs several different products on the target machine.
