Update
有趣的是,如果我运行 32 位 powershell 来运行脚本,它会给我同样的错误。看起来32位powershell无法访问64位注册表树?我尝试使用WixQuietExec64
但它给出了同样的错误。我还尝试提供 powershell 的完整路径(C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
)以确保安装程序启动 64 位版本,但这仍然给出相同的错误...看起来这可能是由于 MSI 安装程序本身是 32 位造成的?
MSI (s) (4C:C0) [14:25:49:955]: Hello, I'm your 32bit Elevated Non-remapped custom action server.
原帖
我有以下内容test.ps1
script:
$exchangeroot = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ExchangeServer\"
$allexchanges = Get-ChildItem -Path Registry::$exchangeroot -Name | Where-Object { $_ -match "^V.." }
$sorted = $allexchanges | Sort-Object -descending
If ($sorted.Count -gt 1) { $latest = $sorted[0] } Else { $latest = $sorted }
$setup = $exchangeroot + $latest + "\Setup"
$properties = Get-ItemProperty -Path Registry::$setup
$properties
在普通 PowerShell 窗口中运行脚本会产生以下输出:
PS C:\Program Files (x86)\TrustValidator Exchange Server Plugin> .\test.ps1
Required machine-level settings. : 1
Services : C:\Program Files\Microsoft\Exchange Server\V15
NewestBuild : 10845
CurrentBuild : 710737954
Information Store Service : 1
Messaging and Collaboration Event Logging : 1
MsiInstallPath : C:\Program Files\Microsoft\Exchange Server\V15\
...
所以它有效。现在从 WiX 安装程序启动 PowerShell 并执行脚本,它不会生成相同的结果:
WixQuietExec: Get-ItemProperty : Cannot find path
WixQuietExec: 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ExchangeServer\v15\Setup' because it
WixQuietExec: does not exist.
WixQuietExec: At C:\Program Files (x86)\TrustValidator Exchange Server Plugin\test.ps1:10
WixQuietExec: char:16
WixQuietExec: + $properties = Get-ItemProperty -Path Registry::$setup
WixQuietExec: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WixQuietExec: + CategoryInfo : ObjectNotFound: (HKEY_LOCAL_MACH...erver\v15\Set
WixQuietExec: up:String) , ItemNotFoundException
WixQuietExec: + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetIt
WixQuietExec: emPropertyCommand
现在,如果我们观察错误消息,就好像它可以访问树,直到HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ExchangeServer\
,因为我的脚本会搜索并列出所有版本,所以v15
到那时为止必须是可访问的,但是当它试图更深入地获取ItemProperty
,不能。
这让我相信,也许我在从 WiX 安装程序启动 PowerShell 时遗漏了一些东西......?
这是我的 wxs 文件中的内容:
<SetProperty Id="InstallPlugin"
Before ="InstallPlugin"
Sequence="execute"
Value =""powershell.exe" -Command "cd '[INSTALLFOLDER]'; & '[#TestPS1]' ; exit $$($Error.Count)"" />
<CustomAction Id="InstallPlugin" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="ignore" Impersonate="no" />
以下是我已经尝试过或仔细检查过的项目列表:
- 我尝试过不同的组合
-NoProfile
, -ExecutionPolicy ByPass
, -Version 2.0
还是不行。
- 我已经运行安装程序
InstallPrivileges="elevated"
- 我已经在运行了
CustomAction
as Execute="deferred"
and Impersonate="no"
- 我尝试过
AdminImage="yes"
- 我尝试过设置
<Property Id="MSIUSEREALADMINDETECTION" Value="1" />
任何其他线索将不胜感激。 :(