开发者

Install Powershell script with WiX

开发者 https://www.devze.com 2022-12-21 20:45 出处:网络
I have a signed PowerShell script which I want to deploy to a target machine via a WiX installer. Is it possible to give the script the execution rights?

I have a signed PowerShell script which I want to deploy to a target machine via a WiX installer. Is it possible to give the script the execution rights?

Regards, forki

  • EDIT - It seems I have to call Powershell with --Command Set-ExecutionPolicy RemoteSigned, but I can't get it working. I see the Powershell command window opening but it doesn't change the policy.
<Property Id="POWERSHELLEXE"><![CDATA[C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe]]></Property>

<CustomAction Id="AllowPS"
  Property="POWERSHELLEXE"
  ExeCommand="-NoLogo -NoProfile -Command Set开发者_StackOverflow社区-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. The -Force parameter will force the change without an additional prompt.


If you are using PowerShell 2.0, there is a -ExecutionPolicy parameter on PowerShell.exe. Try something like this in one single custom action to run the script.

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


I will set the ExecutionPolicy via group policies.

0

精彩评论

暂无评论...
验证码 换一张
取 消