我正在尝试将以下vbscript代码更改为PowerShell [关闭]

问题描述 投票:-3回答:1

我有以下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
powershell vbscript
1个回答
1
投票

使用它在PowerShell中实例化COM对象:

$msi= New-Object -ComObject WindowsInstaller.Installer 
© www.soinside.com 2019 - 2024. All rights reserved.