MSI 从注册表获取安装参数 [英] MSI get install arguments from registry

查看:59
本文介绍了MSI 从注册表获取安装参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们实际上是在编写 PowerShell cmdlet 来创建已安装(自定义)MSI 的快照.cmdlet 遍历服务器列表,检查是否安装了给定发布者的 MSI.如果是这样,MSI 将从远程计算机复制到主机执行 PowerShell cmdlet.到现在为止还挺好.在下一阶段,我们计划使用预先获取的 MSI 包来恢复系统.

We're actually writing PowerShell cmdlets to create a snapshot of installed (custom) MSIs. The cmdlets walk through a list of servers, check if MSIs of a given publisher are installed. If so, the MSI is copied from the remote machine to host executing the PowerShell cmdlet. So far so good. In the next stage we're planning to restore a system with the beforehand fetched MSI packages.

我们的实际问题:一些 MSI 需要命令行参数才能通过 msiexec 安装.如果参数存储在某个地方,我们会搜索 Windows 注册表,但我们无法找到它们.我们检查了以下路径:

Our actual problem: Some of the MSIs need command line parameters for installation via msiexec. We searched the Windows registry if the arguments are stored somewhere, but we were not able to find them. We checked following paths:

 HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\*\InstallProperties
 HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
 HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*

有谁知道在通过 msiexec 安装 MSI 时安装参数是否保留在 Windows 上?

Does anybody knows if the install arguments, when installing an MSI via msiexec, are persisted on Windows?

MSI 软件包通过以下方式安装:

The MSI packages get installed via:

  msiexec /i somePackage.msi /qn /norestart Arg1=1 Arg2=someTest Arg3=true

谢谢

推荐答案

安装字符串:正如 Chris 所说,从安装中持久保存属性是Windows Installer - 在我看来也是如此.我已经多次为这种持久化实现自定义功能,以解决企业部署的限制.

Install Strings: As Chris has stated, the persisting of properties from an installation is an omission from Windows Installer - in my opinion too. I have implemented custom features for such persisting several times to work around the limitation for corporate deployment.

卸载字符串:虽然注册表中没有安装字符串/安装命令行(我知道),有卸载字符串写入注册表,如此处所述.

转换:我想补充一点,如果在安装过程中应用了转换,那么您可以通过 MSI API 获取这些转换的路径.应用转换可以对正在安装的 MSI 进行重大更改,并且与仅设置 PUBLIC PROPERTIES 相比,它是自定义部署的重量级方法.更多信息请访问:如何更好地利用 MSI 文件(转换部分).

要检索应用于您的盒子上的 MSI 包的转换列表(可能没有任何转换 - 大多数公司使用转换进行部署),可以尝试访问 MSI COM API 以获取信息的 VBScript(而不是阅读直接来自注册表 - 这不是那么好,因为原始值可能会受到注册表中未以明文形式显示的实现细节的影响).

To retrieve a list of transforms applied to your MSI package on your box (there might not be any - most corporations use transforms for deployment), maybe try this VBScript which accesses the MSI COM API to get the information (rather than reading directly from the registry - which is not as good since raw values could be affected by implementation details not seen in the registry in clear text).

要运行脚本,请将其复制/粘贴到桌面上的 *.vbs 文件中,然后双击运行.输出到 msiinfo.csv.在 Excel电子表格应用程序或仅记事本中打开:

To run the script, copy / paste it into a *.vbs file on your desktop and double click to run. Output to msiinfo.csv. Open in Excel, a spreadsheet application or just Notepad:

Set fso = CreateObject("Scripting.FileSystemObject")
Set output = fso.CreateTextFile("msiinfo.csv", True, True)
Set installer = CreateObject("WindowsInstaller.Installer")

On Error Resume Next ' we ignore all errors

' Write headers
output.writeline ("ProductCode" & ", " & "ProductName" & ", " & "Version" & ", " & "Transforms")

For Each product In installer.ProductsEx("", "", 7)
   productcode = product.ProductCode
   name = product.InstallProperty("ProductName")
   version=product.InstallProperty("VersionString")
   transforms= product.InstallProperty("Transforms")
   output.writeline (productcode & ", " & name & ", " & version & ", " & transforms)
Next

output.Close

这篇关于MSI 从注册表获取安装参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆