2010-03-05 70 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。