3

i am using this to get the program names, but i need the exe names. How do i find them?

string SoftwareKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products";
RegistryKey rk = default(RegistryKey);
rk = Registry.LocalMachine.OpenSubKey(SoftwareKey);
//string skname = null;
string sname = string.Empty;

foreach (string skname in rk.GetSubKeyNames())
{

  try
    {
       sname = Registry.LocalMachine.OpenSubKey(SoftwareKey).OpenSubKey(skname).OpenSubKey("InstallProperties").GetValue("DisplayName").ToString();
       listBox1.Items.Add(sname);
     }
     catch (Exception ex)
     {
        MessageBox.Show(ex.Message);
     }
}

I am trying to do this:

System.Diagnostics.Process.Start("Name.exe");

to run the program.

Hunter Mitchell
  • 7,063
  • 18
  • 69
  • 116
  • The answer is found Here...[http://stackoverflow.com/questions/8954461/c-sharp-application-scanning][1] [1]: http://stackoverflow.com/questions/8954461/c-sharp-application-scanning – Hunter Mitchell Jul 04 '12 at 05:17
  • The question above was asking to find and display all the installed applications. To find all exe, the only way to do is to do a recursive search on a root directory for `*.exe` – Harvey Kwok Jul 04 '12 at 05:23

3 Answers3

0

The installer doesn't, and really couldn't, know about the actuall executables. It only knows about the installation package - the .MSI file.

In order to get the names of the executables (yes, many "programs" are composed of numerous .EXE files) you would need to interrogate the .MSI file.

Sam Axe
  • 33,313
  • 9
  • 55
  • 89
0

In Windows, programs are normally installed by msi file and there can be multiple exe installed by a single package. It's true that sometimes programs are installed by setup.exe but they are just a wrapper extracting the real msi file.

Some vendor like InstallShield might store the setup.exe somewhere in the local harddrive just in case user needs to launch the setup.exe again for modify\uninstallation purpose. However, this is vendor specific implementation.

Harvey Kwok
  • 11,713
  • 6
  • 37
  • 59
  • @Elite exe file is not required to be registered in registry and actually in most cases, they are not in registry. Imagine you just compile a test.exe and put it in `c:\test\` folder, how can you find the `test.exe` from registry? Please describe exactly what you are trying to do – Harvey Kwok Jul 04 '12 at 05:15
0

Lacking a clarification on the particulars, you can get the .exe's on local drives as such:

var allExePaths =
    from drive in Environment.GetLogicalDrives()
    from exePath in Directory.GetFiles(drive, "*.exe", SearchOption.AllDirectories)
    select exePath;

If you're looking for a particular one, please provide more details about what things will determine the one you're looking for. Using the registry to list installed programs doesn't seem to be what you want to do, so please be more specific.

James Manning
  • 13,429
  • 2
  • 40
  • 64