0

I need to find the path which on running it in Command Prompt will open the application.

For an instance- I have Picasa 3 installed on my system, using below code I'm able to access the installed folder location.

private string FindByDisplayName(RegistryKey parentKey, string name)
        {
            string[] nameList = parentKey.GetSubKeyNames();
            for (int i = 0; i < nameList.Length; i++)
            {
                RegistryKey regKey = parentKey.OpenSubKey(nameList[i]);
                try
                {
                    if (regKey.GetValue("DisplayName").ToString() == name)
                    {
                        return regKey.GetValue("InstallLocation").ToString();
                    }
                }
                catch { }
            }
            return "";
        }
        private void button1_Click(object sender, EventArgs e)
        {
            String AppName = textBox1.Text.ToString();
            RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
            string location = FindByDisplayName(regKey, AppName);
            MessageBox.Show(location);
        }

The output of this code will give me-

C:\Program Files(x86)\Google\Picasa 3

But I want exact .exe file which will open the Picasa 3 Desktop App because as above output location contains more than one executable file eg: one for opening the app, other is for uninstalling it.

Hope my question is clear to all.

Arpan Arora
  • 109
  • 7
  • you want to know what is the "caller" application?? – NicoRiff Mar 02 '17 at 17:41
  • Yes,I want to extract the path of Application which upon running in CMD opens the desired application. As in above example in question I want to extract complete path for "Picasa 3.exe" – Arpan Arora Mar 02 '17 at 17:46
  • And Input for above code is just the name of application eg: "Picasa 3" for above question – Arpan Arora Mar 02 '17 at 17:56
  • [This](https://stackoverflow.com/questions/909910/how-to-find-the-execution-path-of-a-installed-software) might give you some ideas, but it will not work for every app. – Bogdan Pătrăucean Dec 03 '22 at 19:23

0 Answers0