2010-03-05 100 views
3

我有一个已签名的PowerShell脚本,我想通过WiX安装程序将其部署到目标计算机。是否可以赋予剧本执行权?使用WiX安装Powershell脚本

问候, forki

  • 编辑 - 看来我得叫PowerShell和--command的Set-ExecutionPolicy RemoteSigned就是,但我无法得到它的工作。我看到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> 
+0

看来我必须使用--Command Set-ExecutionPolicy RemoteSigned来调用Powershell,但是我无法让它工作。 – forki23 2010-03-05 12:37:34

+0

您是否在目标机器上使用PowerShell 1.0或2.0? – Goyuix 2010-03-05 16:24:54

+0

我们有赢7 - 所以我认为它是2.0。 – forki23 2010-03-05 16:32:50

回答

3

组策略是更好的办法去了解它,

我认为你要PowerShell.exe呼叫未更改执行策略的原因是因为该cmdlet设置更改执行之前提示用户政策。 -Force参数将在没有附加提示的情况下强制更改。

2

如果你正在使用PowerShell 2.0中,对PowerShell.exe一个-ExecutionPolicy参数。在一个自定义操作中尝试这样的操作来运行脚本。

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

你有一个错字 - 应该是'RemoteSigned' – Eternal21 2017-10-23 14:54:55

1

我将通过组策略设置ExecutionPolicy。