Val*_*tor 5 windows powershell wix
我有一个 WiX 安装程序,需要在安装后运行 Powershell 脚本。我已经到了安装程序实际上运行脚本的地步:
<SetProperty Id="RunStartScript"
Before ="RunStartScript"
Sequence="execute"
Value=""C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NonInteractive -ExecutionPolicy Bypass -InputFormat None -NoProfile -File "[INSTALLDIR]Scripts/Start.ps1"" />
<CustomAction Id="RunStartScript" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="yes" />
<InstallExecuteSequence>
<Custom Action="RunStartScript" Before="InstallFinalize">NOT Installed OR UPGRADINGPRODUCTCODE</Custom>
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)
但是,msi 失败并出现以下错误:
脚本“Start.ps1”无法运行,因为它包含以管理员身份运行的“#requires”语句。当前 Windows PowerShell 会话未以管理员身份运行。使用“以管理员身份运行”选项启动 Windows PowerShell,然后尝试再次运行该脚本。
安装程序在安装开始之前已经提示输入管理员身份,因此我假设 PowerShell 命令已经以管理员身份运行,但事实并非如此。
我找到了一些答案,涉及在脚本开头添加代码以检查管理员权限并将命令和参数传递给管理会话,但我正在寻找另一个选项的可能性,因为这是一个签名脚本其他人提供的,因此对其进行的任何更改都必须返回给他们重新签名。