简体   繁体   English

使用WiX安装Powershell脚本

[英]Install Powershell script with WiX

I have a signed PowerShell script which I want to deploy to a target machine via a WiX installer. 我有一个签名的PowerShell脚本,我想通过WiX安装程序部署到目标机器。 Is it possible to give the script the execution rights? 是否可以为脚本提供执行权限?

Regards, forki 此致,forki

  • EDIT - It seems I have to call Powershell with --Command Set-ExecutionPolicy RemoteSigned, but I can't get it working. 编辑 - 似乎我必须使用--Command Set-ExecutionPolicy RemoteSigned调用Powershell,但我不能让它工作。 I see the Powershell command window opening but it doesn't change the policy. 我看到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> 

Group Policy is the better way to go about it, 组策略是更好的方法,

I think the reason that your call to PowerShell.exe is not changing the execution policy is because the cmdlet is set to prompt the user before changing the execution policy. 我认为您对PowerShell.exe的调用没有更改执行策略的原因是因为cmdlet设置为在更改执行策略之前提示用户。 The -Force parameter will force the change without an additional prompt. -Force参数将强制进行更改,而无需其他提示。

If you are using PowerShell 2.0, there is a -ExecutionPolicy parameter on PowerShell.exe. 如果您使用的是PowerShell 2.0,则PowerShell.exe上会出现-ExecutionPolicy参数。 Try something like this in one single custom action to run the script. 在一个自定义操作中尝试这样的操作来运行脚本。

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

我将通过组策略设置ExecutionPolicy。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM