在C#中获取已安装程序的exe名称?

在C#中获取已安装程序的exe名称?

问题描述:

我正在使用它来获取程序名称,但是我需要exe名称.我如何找到他们?

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);
     }
}

我正在尝试这样做:

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

运行程序.

安装程序实际上并不知道实际的可执行文件.它只知道安装包-.MSI文件.

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

为了获取可执行文件的名称(是的,许多程序"由许多.EXE文件组成),您需要查询.MSI文件.

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.