作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用Powershell编辑MSI文件。我几乎可以编辑每个表,但“SummaryInformation”部分实际上不是一个与其他表相同的表。
我可以毫无问题地从这些信息中读取属性,但是我什么也不能做。
从我能够在线找到的信息中,我应该能够使用
$SummaryInfo.GetType().InvokeMember("Property", "SetProperty”, $null, $SummaryInfo,@(3,'test'))
Exception calling "InvokeMember" with "5" argument(s): "Property,Pid"
$MSIPATH = "Path To MSI File"
$windowsInstaller = New-Object -ComObject WindowsInstaller.Installer
$MSIDatabase = $windowsInstaller.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $Null, $windowsInstaller, @($MSIPATH, 1))
$SummaryInfo = $MSIDatabase.GetType().InvokeMember(“SummaryInformation”, “GetProperty”,$Null , $MSIDatabase, $Null)
#get the porperty that I want to set
$SummaryInfo.GetType().InvokeMember(“Property”, “GetProperty”, $null, $SummaryInfo, @(3))
#Attempt to set the property this fails
$SummaryInfo.GetType().InvokeMember("Property", "SetProperty”, $null, $SummaryInfo,@(3,'test'))
$windowsInstaller = New-Object -ComObject WindowsInstaller.Installer
$MSI = $windowsInstaller.OpenDatabase("Path to MSI", 1)
$SummaryInfo = $MSI.SummaryInformation(4)
$SummaryInfo.Property(3) = "Test"
$SummaryInfo.Persist()
$MSI.Commit()
最佳答案
感谢mklement0我找到了解决方案
我无法以与编辑其他表相同的方式进行操作。但是已经找到了通过使用直接调用的解决方案。
代码像这样
$windowsInstaller = New-Object -ComObject WindowsInstaller.Installer
$MSI = $windowsInstaller.OpenDatabase("Path to MSI", 1)
$SummaryInfo = $MSI.SummaryInformation(4)
$SummaryInfo.Property(3) = "Test"
$SummaryInfo.Persist()
$MSI.Commit()
关于powershell - 使用Powershell在MSI中设置SummaryInformation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53199158/
我是一名优秀的程序员,十分优秀!