从Windows命令行获取已安装的应用程序列表


34

我曾经看到一个人运行命令,并获得了他计算机上所有已安装应用程序的列表。我该怎么做呢?

我想要我当前安装的应用程序的列表。我相信他以某种方式使用了WSH


Answers:


39

如果您使用Windows Vista或Windows 7,并且不想安装其他软件,则可以:

  1. 打开命令行窗口(Windows+ R,CMD.EXE)
  2. 类型wmicEnter
  3. 类型product get nameEnter

+1这些天,WMI无法告诉您有关您计算机的信息。
GAThrawn

5
这里说Win32_Product不会提供有关已安装软件的所有信息。这意味着,它不会列出所有软件。原因是,win32_product查询MSI数据库以获取列表。但是将有许多从exe安装的软件中没有任何条目。在这种情况下,查询卸载注册表项将提供有关这些软件的信息。
悲惨的变量2012年

1
@MiserableVariable它说了吗?(链接错误吗?)如何以类似的方式查询卸载注册表?(或也许通过使用wmic?)
JeromeJ 2016年

1
也可用于Windows 10
Turcia '16

5
是我自己,还是运行得很慢?
user3083324

27

如果在运行软件时使用-s标志,则Microsoft / Sysinternals的PsInfo可以列出所有已安装的软件。您还可以使用-c将其输出为csv文件,例如在Excel中使用。

C:\> psinfo -s > software.txt
C:\> psinfo -s -c > software.csv

1
与WMI解决方案相比,也可以在Win XP下使用
Gerd Klima 2009年

不显示上所有已安装的软件Windows 2012 R2 x64。我正在使用PsInfo ver. 1.77
Tomasito,

这种方法在我的笔记本电脑上产生了933个项目,而WMI方法仅产生了598个项目。它似乎产生了更大的清单...
Andrej Adamenko

@djhowell:我试图在Windows 7中执行命令,但出现错误“ psinfo is not recognized as an internal or external command, operable program or batch file.”。即使在提升权限的cmd窗口中也会发生这种情况。
skm

14

列出它们的PowerShell脚本:

$loc = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall

$names = $loc |foreach-object {Get-ItemProperty $_.PsPath}

foreach ($name in $names)
{
    Write-Host $name.Displayname
}

不完全是命令行,但是为此,我个人使用CCleaner的卸载工具,您可以将已安装软件的列表导出到文本文件:

替代文字


2
颇具讽刺意味的是,Windows Powershell等工具需要花很长时间才能运行(> 5分钟),但CCleaner却是即时的。
CAD bloke'Aug

6

也不完全是命令行,但是可信赖的旧SIW也可以完成此工作。高亮显示应用程序,右键单击→ 导出到CSV,HTML,TXT或XML

替代文字

SIW是免费软件,可移植,不需要安装。


我一直都知道SIW需要许可证,您从何处获得了免费软件?
特纳

3

除非您确定要使用命令行,否则上述CCleaner解决方案似乎是解决问题的一种不错的方法。我以前使用过CCleaner,这是一个很好的工具,但是请不要假定所有内容都已在“添加/删除程序”小程序(相同的列表)中注册。有许多使用xcopy样式安装的应用程序,即简单地解压缩此存档并运行。这些将不会显示在列表中。


3

要添加到MicTech的解决方案中,请使用wmic已安装软件的列表并将其捕获到文件中:

打开命令行窗口(Windows+ R,CMD.EXE)

wmic /OUTPUT:my_software.txt product get name

2

Sysinternals psinfo.exe提供了所有建议中的最完整信息,它可以直接从提升的CMD提示符从命令行在任何Windows PC上运行,而无需永久下载:

\\live.sysinternals.com\tools\psinfo.exe -s > %userprofile%\Desktop\_psinfo.txt

运行此命令时,将出现安全提示,而EULA提示在计算机上的第一次提示。文本文件将保存到当前桌面。

可以自动接受EULA,如下所示:

\\live.sysinternals.com\tools\psinfo.exe -s /accepteula > %userprofile%\Desktop\_psinfo.txt


0

通过Windows注册表在C#安装的程序中的编码版本:

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;


namespace SoftwareInventory
{
    class Program
    {
        static void Main(string[] args)
        {
            //!!!!! Must be launched with a domain administrator user!!!!!
            Console.ForegroundColor = ConsoleColor.Green;
            StringBuilder sbOutFile = new StringBuilder();
            Console.WriteLine("DisplayName;IdentifyingNumber");
            sbOutFile.AppendLine("Machine;DisplayName;Version");

            // Retrieve machine name from the file :File_In/collectionMachines.txt
            //string[] lines = new string[] { "NameMachine" };
            string[] lines = File.ReadAllLines(@"File_In/collectionMachines.txt");
            foreach (var machine in lines)
            {
                // Retrieve the list of installed programs for each extrapolated machine name
                var registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
                using (Microsoft.Win32.RegistryKey key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, machine).OpenSubKey(registry_key))
                {
                    foreach (string subkey_name in key.GetSubKeyNames())
                    {
                        using (RegistryKey subkey = key.OpenSubKey(subkey_name))
                        {
                            //Console.WriteLine(subkey.GetValue("DisplayName"));
                            //Console.WriteLine(subkey.GetValue("IdentifyingNumber"));
                            if (subkey.GetValue("DisplayName") != null)
                            {
                                Console.WriteLine(string.Format("{0};{1};{2}", machine, subkey.GetValue("DisplayName"), subkey.GetValue("Version")));
                                sbOutFile.AppendLine(string.Format("{0};{1};{2}", machine, subkey.GetValue("DisplayName"), subkey.GetValue("Version")));
                            }
                        }
                    }
                }
            }
            // CSV file creation
            var fileOutName = string.Format(@"File_Out\{0}_{1}.csv", "Software_Inventory", DateTime.Now.ToString("yyyy_MM_dd_HH_mmssfff"));
            using (var file = new System.IO.StreamWriter(fileOutName))
            {
                file.WriteLine(sbOutFile.ToString());
            }

            // Press Enter to continue 
            Console.WriteLine("Press enter to continue!");
            Console.ReadLine();
        }
    }
}
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.