I want to find the file path of a program installed on my computer. The following code is running to check if the program is installed. But when I want to read the InstallLocation in the registry, it returns an empty value.
Is there a situation that needs to be specifically specified while installing the program?
I tried the alternative ways here. The third answer shows the file path. But even if the program is removed, the answer still returns and it didn't seem like a healthy way.
Is there an alternative method to find the file path? If the problem is in the WixSetup installation, what is the point I need to fix? I can share the WixSetup codes as needed.
Note: I am using WixSetup for installation.
public static bool IsProgramInstalled(string programDisplayName)
{
foreach (var item in Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall").GetSubKeyNames())
{
object programName = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + item).GetValue("DisplayName");
if (string.Equals(programName, programDisplayName))
{
string location = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + item).GetValue("InstallLocation").ToString();
return true;
}
}
return false;
}