windows 如何从命令行列出已安装的 MSI?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/198087/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:33:40  来源:igfitidea点击:

How do I list installed MSI from the command line?

windowswindows-installer

提问by bltxd

We recently switched our Windows software packages from RPM (cygwin) to MSI (wix). Having a native packaging is a much welcome change and we intend to stick with it. However, MSI feels overly complicated for what it does and doesn't seem to provide some basic abilities. But I'm probably mistaken.

我们最近将 Windows 软件包从 RPM (cygwin) 切换到 MSI (wix)。拥有原生包装是一个非常受欢迎的变化,我们打算坚持下去。但是,MSI 感觉它的功能过于复杂,并且似乎没有提供一些基本功能。但我可能错了。

Is there a way to list all installed MSI from the command line ?

有没有办法从命令行列出所有已安装的 MSI?

采纳答案by Node

Mabybe thisis a good starting point for you example VB Script from MSDN:

Mabybe是 MSDN 示例 VB 脚本的一个很好的起点:

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & _
    "{impersonationLevel=impersonate}!\" & _
    strComputer & _
    "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Product")   

If colSoftware.Count > 0 Then

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.CreateTextFile( _
        "c:\SoftwareList.txt", True)

    For Each objSoftware in colSoftware
        objTextFile.WriteLine objSoftware.Caption & vbtab & _
        objSoftware.Version
    Next

    objTextFile.Close

Else
    WScript.Echo "Cannot retrieve software from this computer."

End If

回答by knut

You may use PowerShelland Windows Management Instrumentation (WMI). Here is a one liner:

您可以使用PowerShellWindows Management Instrumentation (WMI)。这是一个单班轮:

Get-WmiObject -Class win32_product

Here is help for the Get-WmiObjectcmdlet:

这是Get-WmiObjectcmdlet 的帮助:

http://technet.microsoft.com/en-us/library/dd315295.aspx

http://technet.microsoft.com/en-us/library/dd315295.aspx

Here is a sample where we select the first installed program and format it as a table:

这是我们选择第一个安装的程序并将其格式化为表格的示例:

PS C:\Users\knut> Get-WmiObject -Class win32_product |
>> select -First 1 | ft Name, Version, Vendor -AutoSize
>>

Name             Version  Vendor
----             -------  ------
AWS SDK for .NET 1.2.0200 Amazon Web Services Developer Relations

回答by Ferruccio

I'm not sure if this is what you need but you can query the uninstall list from the command line with:

我不确定这是否是您需要的,但您可以使用以下命令从命令行查询卸载列表:

REG QUERY HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall