我有以下VBScript代码,我试图在PowerShell中重写。
我遇到了CreateObject("WindowsInstaller.Installer")
的问题。我无法在Powershell中做到这一点。我希望看到对象的Products,ProductCode和PatchCode属性。
有人可以帮忙吗? VB代码如下。
Dim msi : Set msi = CreateObject("WindowsInstaller.Installer")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("output.txt", True)
Dim products : Set products = msi.Products
Dim productCode
For Each productCode in products
Dim patches : Set patches = msi.Patches(productCode)
Dim patchCode
For Each patchCode in patches
Dim location : location = msi.PatchInfo(patchCode, "LocalPackage")
objFile.WriteLine location
Next
Next
答案 0 :(得分:1)
使用它在PowerShell中实例化COM对象:
$msi= New-Object -ComObject WindowsInstaller.Installer