Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 以管理员身份在WiX安装中运行Powershell脚本_Windows_Powershell_Wix - Fatal编程技术网

Windows 以管理员身份在WiX安装中运行Powershell脚本

Windows 以管理员身份在WiX安装中运行Powershell脚本,windows,powershell,wix,Windows,Powershell,Wix,我有一个WiX安装程序,需要在安装后运行Powershell脚本。我已经到了安装程序实际运行脚本时使用以下内容的地步: <SetProperty Id="RunStartScript" Before ="RunStartScript" Sequence="execute" Value="&quot;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&quot; -

我有一个WiX安装程序,需要在安装后运行Powershell脚本。我已经到了安装程序实际运行脚本时使用以下内容的地步:

<SetProperty Id="RunStartScript"
        Before ="RunStartScript"
        Sequence="execute"
        Value="&quot;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&quot; -NonInteractive -ExecutionPolicy Bypass -InputFormat None -NoProfile -File &quot;[INSTALLDIR]Scripts/Start.ps1&quot;" />

<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>

未安装或升级ProductCode
但是,msi因以下错误而失败:

无法运行脚本“Start.ps1”,因为它包含以管理员身份运行的“#requires”语句。当前Windows PowerShell会话未以管理员身份运行。使用“以管理员身份运行”选项启动Windows PowerShell,然后再次尝试运行该脚本

安装程序在安装开始之前已经提示输入管理员,因此我假设PowerShell命令已经以管理员身份运行,但情况肯定不是这样


我找到了一些答案,包括在脚本开头添加代码,以检查管理员权限,并将命令和参数传递给管理员会话,但是我正在寻找另一个选项的可能性,因为这是一个别人提供的签名脚本,所以对它的任何更改都必须返回给他们重新签名。

需要将
Impersonate=“yes”
更改为
Impersonate=“no”
,这样Powershell会话就不会以普通用户的身份运行