I am having trouble reading this key from my managed bootstrapper (.NET 4.5.2), and my custom action (tried .NET 2.0 and 4.0).
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages
I tried running the bootstrapper and msi using cmd as Administrator. My test environment is Windows 7 64-bit. I am using Wix 3.11
I made a test command line app and it was able to access this key.
The testing code I used in the bootstrapper and custom action:
static RegistryKey GetHKLMKey(string registryPath) {
var hklm64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
var registryKey64 = hklm64.OpenSubKey(registryPath);
if ((registryKey64?.GetValueNames().Any()).GetValueOrDefault()) {
return registryKey64;
}
var hklm32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
return hklm32.OpenSubKey(registryPath);
}
}
...
var path = @"SOFTWARE";
foreach (var segment in @"Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages".Split('\\')) {
path += "\\"+segment;
var j = GetHKLMKey(path);
Log(path + ": " + j);
var k = Registry.LocalMachine.OpenSubKey(path);
Log(path + ": " + k);
if (k == null) return true;
}
test output
SOFTWARE\Microsoft: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft
SOFTWARE\Microsoft: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft
SOFTWARE\Microsoft\Windows: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
SOFTWARE\Microsoft\Windows: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
SOFTWARE\Microsoft\Windows\CurrentVersion: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
SOFTWARE\Microsoft\Windows\CurrentVersion: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing
SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing
SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages:
SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages:
if ((registryKey64?.GetValueNames().Any()).GetValueOrDefault()) {
. I changed toif(registryKey64 != null) {
and it's working as intended. Your "Debug C# Custom Actions" was helpful. – Liking