Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get another application's installation path programmatically?

I'd like to know where the installation path for an application is. I know it usually is in ...\Program Files... but I guess some people install it in different locations. I do know the name of the application.

Thank you.

like image 672
Alex Avatar asked Oct 12 '10 16:10

Alex


People also ask

How to get installation path of an application in c#?

extracts the directory. string envPath = Environment. GetEnvironmentVariable("PATH"); Environment. SetEnvironmentVariable(envPath + ";" + yourPath);

How do I find the installation directory of a program?

To find the installation folder of a program using a desktop shortcut: From your desktop, right-click on the program's shortcut. Click on the Properties, and the Properties window should now be displayed. Click on the Shortcut tab, and you will find the installation path in the Target field.

What is a install path?

The installation path is the folder, relative to your domain name's document root folder. For example, if the installation path is “/” this means that your website will appear when someone types in yourdomain.com in their browser.


4 Answers

Many (most?) programs create an App Paths registry key. Have a look at

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
like image 113
Andreas Rejbrand Avatar answered Oct 21 '22 18:10

Andreas Rejbrand


If you know the application in question (as compared to any application) registry key is the probably the best option (if one exists).

The install might put in its own custom "install path key" somewhere (so do a find as Fara mentioned) or it might be in the uninstall section for installed programs, so you could check:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

But be aware that any new version of an install could change the key it writes out, both for a custom key or for the uninstall entry. So checking the registry should probably be only for a known install\version.

tep

like image 42
Gern Blanston Avatar answered Oct 21 '22 19:10

Gern Blanston


The ideal way to find a program's installation path (on Windows) is to read it from the registry. Most installers will create a registry key for that program that contains the installation path. Exactly where this key is and what it will be named varies depending on the program in question.

To find if the program has a key in the registry, open 'regedit' and use the Edit > Find option to try and locate a key with the program name. If such a key exists, you can read it using the RegistryKey class in the .NET Framework library.

If the program does not have a registry key then another option is just to ask the user to locate the .exe file with the OpenFileDialog, although this is obviously not ideal.

like image 12
Alex McBride Avatar answered Oct 21 '22 19:10

Alex McBride


Best way is to use Installer APIs to find the program location. You can write a Managed wrapper over the APIs

Search for MsiGetProductInfo

Reference: http://msdn.microsoft.com/en-us/library/aa369558(VS.85).aspx

like image 3
Sandeep Singh Rawat Avatar answered Oct 21 '22 20:10

Sandeep Singh Rawat