Bra*_*gel 6 powershell windows-installer
堆垛机、
我正在尝试(从 Chrome Enterprise 的 MSI)获取版本号。将 Chrome 下载为 .MSI 后,我注意到我可以看到许多属性。我希望能够访问并构建“if 语句”的是“注释”部分。

当我尝试使用 Get-Item 并将其格式化为列表时,它说其中没有任何内容,我似乎无法确定要做什么。
(Get-Item ".\Chrome.msi").VersionInfo | fl
Run Code Online (Sandbox Code Playgroud)
该命令返回:

如何提取“评论”部分及其数据?
这些属性不存储在或System.IO.FileInfo返回的对象中。解决方案是使用COM 对象为您检索这些属性:Get-ItemGet-Commandshell.application
$filePath = ".\Chrome.msi"
$parentPath = (Resolve-Path -Path (Split-Path -Path $filePath)).Path
$fileName = Split-Path -Path $filePath -Leaf
$shell = New-Object -COMObject Shell.Application
$shellFolder = $Shell.NameSpace($parentPath)
$shellFile = $ShellFolder.ParseName($fileName)
$shellFolder.GetDetailsOf($shellFile,24)
Run Code Online (Sandbox Code Playgroud)
24,是您要查找的特定属性的 ID,因此在本例中,需要注释.GetDetailsOf(.,.)来获取该信息。幸运的是,我之前也在尝试解析评论时遇到过这个问题。我不记得在哪里,但是,我找到了上面提出的解决方案,因此当我可以再次找到它时,我将链接它。
| 归档时间: |
|
| 查看次数: |
8060 次 |
| 最近记录: |