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.