使用WiX安装Powershell脚本

时间:2010-03-05 08:59:51

标签: command-line powershell wix windows-installer

我有一个签名的PowerShell脚本,我希望通过WiX安装程序将其部署到目标计算机。是否可以为脚本提供执行权限?

此致   forki

  • 编辑 - 看来我必须用--Command Set-ExecutionPolicy RemoteSigned调用Powershell,但是我无法让它工作。我看到Powershell命令窗口打开但它不会更改策略。
<Property Id="POWERSHELLEXE"><![CDATA[C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe]]></Property>

<CustomAction Id="AllowPS"
  Property="POWERSHELLEXE"
  ExeCommand="-NoLogo -NoProfile -Command Set-ExecutionPolicy RemoteSigned"
  Execute="deferred"
  Return="check"/>

<InstallExecuteSequence>
   ..
  <Custom Action="AllowPS" Before="InstallFinalize"/>
   ...
</InstallExecuteSequence>

3 个答案:

答案 0 :(得分:3)

组策略是更好的方法,

我认为您对PowerShell.exe的调用未更改执行策略的原因是因为cmdlet设置为在更改执行策略之前提示用户。 -Force参数将强制进行更改而无需其他提示。

答案 1 :(得分:2)

如果您使用的是PowerShell 2.0,则PowerShell.exe上会出现-ExecutionPolicy参数。在一个自定义操作中尝试这样的操作来运行脚本。

ExeCommand="-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -File <scrptpath>"

答案 2 :(得分:1)

我将通过组策略设置ExecutionPolicy。

相关问题