PowerShell Windows Installer Com对象 [英] PowerShell Windows Installer Com Object

查看:123
本文介绍了PowerShell Windows Installer Com对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Powershell修改MSI文件的内容.为此,我创建WindowsInstaller.Instance的实例,然后使用$ installer.OpenDatabase和$ database.OpenView.类似的功能可以在VBScript中使用,而且我在网上看到了似乎可以正常工作的示例.

I'm trying to modify the contents of an MSI file using Powershell. To do so I create an instance of a WindowsInstaller.Installer then use $installer.OpenDatabase and $database.OpenView. Similar functionality works in VBScript and I've seen samples on-line that appear to work.

$installer = new-object -comobject "WindowsInstaller.Installer"
$database = $installer.OpenDatabase("C:\Temp\Setup.msi", 1)

对于上面的代码,我收到一个错误由于[System .__ ComObject]不包含名为'OpenDatabase'的方法,所以方法调用失败."

For the above code, I get an error "Method invocation failed because [System.__ComObject] doesn't contain a method named 'OpenDatabase'."

$installer = new-object -comobject "WindowsInstaller.Installer"
$database = $installer.InvokeMethod("OpenDatabase","C:\Temp\Setup.msi", 1)

如果我尝试使用$ installer.InvokeMethod,则会收到相同的错误由于[System .__ ComObject]不包含名为'InvokeMethod'的方法,所以方法调用失败."

If I attempt to use $installer.InvokeMethod I get the same error "Method invocation failed because [System.__ComObject] doesn't contain a method named 'InvokeMethod'."

任何帮助将不胜感激.

谢谢.

推荐答案

请参见

See the this thread for some guidance. Basically the MSI COM object is implemented in a way that confuses PS. There is a link to a blog post discussing it in that thread.

这篇关于PowerShell Windows Installer Com对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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