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
How do I list installed MSI from the command line?
提问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:
您可以使用PowerShell和Windows Management Instrumentation (WMI)。这是一个单班轮:
Get-WmiObject -Class win32_product
Here is help for the Get-WmiObject
cmdlet:
这是Get-WmiObject
cmdlet 的帮助:
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