I need to check where a program is installed by program name (name that appears in Add or Remove Programs). What is the best way to that so that it'd work fine for all languages.
Asked
Active
Viewed 1.4k times
3 Answers
13
Take a look into the registry at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
Just iterate over all subkeys and take a look into the values DisplayName and InstallLocation. Here you'll find the infos you want and much more ;-)

Oliver
- 43,366
- 8
- 94
- 151
-
At least the InstallLocation can be a work of fiction; for instance, the InstallLocation, according to the registry, for Crystal 11 is "C:\Program Files\Your Company Name\Your Product Name\". In a lot of cases, it is not set, either. – Rowland Shaw Sep 22 '09 at 08:06
10
To add to Oliver's answer I have wrapped up this check inside a static method.
public static bool IsProgramInstalled(string programDisplayName) {
Console.WriteLine(string.Format("Checking install status of: {0}", 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");
Console.WriteLine(programName);
if (string.Equals(programName, programDisplayName)) {
Console.WriteLine("Install status: INSTALLED");
return true;
}
}
Console.WriteLine("Install status: NOT INSTALLED");
return false;
}
4

Adriaan Stander
- 162,879
- 31
- 289
- 284
-
MsiGetProductInfo worked well for me in C#. Use pinvoke(http://www.pinvoke.net/default.aspx/msi.msigetproductinfo) to use the function. – Adam Bruss Oct 01 '12 at 15:09
-
If you want to avoid using PInvoke I think this information can be gotten via Deployment Tools Foundation (DTF), a part of WiX. http://robmensching.com/blog/posts/2008/5/16/deployment-tools-foundation-joins-the-wix-toolset – RenniePet Jun 24 '13 at 15:39