找到所有已安装应用程序的注册表路径

11

我有一个快速的问题:

除了以下这两个地方以外:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

还有其他在注册表中可以找到已安装应用程序的地方吗? 我问这个是因为比如IExplorer不在上述任何一个注册表中。我需要知道所有应用程序安装的可能位置。

谢谢你的帮助;)


你是指iexplore.exe吗? - somebadhat
4个回答

7
你最可靠的选择可能是使用Windows管理界面(WMI)来枚举由Windows Installer安装的软件。
请参阅以下内容: 枚举已安装软件 Win32_Product类 请注意,这并不能保证Internet Explorer会出现在那里。 我认为您可以安全地假设Internet Explorer将出现在当前所有Windows计算机上; Microsoft将其视为操作系统的一部分。
但是,您可以找到已安装的IE版本。
请参阅以下内容: 查找已安装的IE版本

1
当wmic没有列出所有内容时,如何找到它? - jeromej
wmic 不能详尽地列出已安装的软件。它不能被视为“最可靠的选项”。 - seongjoo
现在在Windows10中,WMI方法不如使用卸载和app_path子键可靠。大多数的InstallLocation未设置,很多应用也没有列出来。 - laishiekai

1

这个问题中的路径不包括用户级别安装的应用程序。

它们位于相同的位置,但在 HKEY_CURRENT_USER 下而不是 HKEY_LOCAL_MACHINE 下。

因此总体来说:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

但是正如你所知,HKEY_CURRENT_USER 只适用于当前用户。

要访问所有用户,可以使用 HKEY_USERS 注册表根键,其中包含每个用户的文件夹。

因此,您需要使用以下内容:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

for each user sid under HKEY_USERS:
  HKEY_USERS\<user sid>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
  HKEY_USERS\<user sid>\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

附言:如果您想将用户的SID与其名称匹配,可以在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\<user sid>中查找名为ProfileImagePath的键,该键应等于C:\Users\<user name>。并非所有用户都具有此键,我认为这些是系统用户或您不想触及的内容。


0

#Reg.exe在system32中,但如果您将其复制到脚本源路径中,则会起作用...# reg.exe查询\servername\HKLM\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall


0

我一开始在寻找这个信息,但过了一会儿,我想起来我已经为此编写了一个程序。无论是为每个人,还是为将来的我。

class Program
{
    //using Microsoft.Win32;
    //using System.IO;
    static void Main(string[] args)
    {
        string uninstallKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
        RegistryKey regKey = Registry.LocalMachine.OpenSubKey(uninstallKey);
        string[] subKey = regKey.GetSubKeyNames().Select((c)=>
        {
            RegistryKey rk = regKey.OpenSubKey(c);
            string displayName = (string)rk.GetValue("DisplayName");
            if (string.IsNullOrEmpty(displayName)) return "";
            return displayName + string.Format(" => [{0}]", c);
        }).ToArray<string>();
        string filename = "ProgramList.txt";
        if (File.Exists(filename)) File.Delete(filename);
        StreamWriter sw = File.CreateText(filename);
        foreach (string appName in subKey.OrderBy(c=>c))
        {
            if (appName != "" && !appName.StartsWith("{"))
            {
                Console.WriteLine(appName);
                sw.WriteLine(appName);
            }
        }
        sw.Close();
    }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接