Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取C#中已安装程序的exe名称?_C#_Winforms_Registry_Visual C# Express 2010 - Fatal编程技术网

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

获取C#中已安装程序的exe名称?,c#,winforms,registry,visual-c#-express-2010,C#,Winforms,Registry,Visual C# Express 2010,我用这个来获取程序名,但我需要exe名。我怎么找到他们 string SoftwareKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products"; RegistryKey rk = default(RegistryKey); rk = Registry.LocalMachine.OpenSubKey(SoftwareKey); //string skname = nul

我用这个来获取程序名,但我需要exe名。我怎么找到他们

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文件


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

在Windows中,程序通常由MSI文件安装,单个软件包可以安装多个EXE。的确,有时程序是由setup.exe安装的,但它们只是提取真实msi文件的包装器


某些供应商(如InstallShield)可能会将setup.exe存储在本地硬盘驱动器的某个位置,以防用户出于修改\卸载目的再次启动setup.exe。但是,这是特定于供应商的实现。

如果没有详细说明,您可以在本地驱动器上获得.exe:

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

如果你正在寻找一个特定的,请提供更多的细节,什么事情将决定你正在寻找的。使用注册表列出已安装的程序似乎不是您想要做的,因此请更具体一些。

@Elite exe文件不需要在注册表中注册,实际上在大多数情况下,它们不在注册表中。假设您只是编译一个test.exe并将其放入
c:\test`文件夹中,您如何从注册表中找到
test.exe`呢?请准确描述您试图做的事情答案在这里…[[1]:上面的问题是要查找并显示所有已安装的应用程序。要查找所有exe,唯一的方法是在根目录上递归搜索
*。exe
即使我以管理员身份运行它,也会引发异常(授权错误)