简体   繁体   English

在NSIS中运行powershell命令会抛出对路径的访问已被拒绝

[英]Running powershell command in NSIS throws Access to the path has been denied

We need to run a powershell comman in our NSIS installer. 我们需要在NSIS安装程序中运行一个powershell命令。 Running the command in the powershell is no problem and running the command with 在Powershell中运行命令没有问题,并且使用

'powershell.exe "& "our command here"'

in the windows command line is no problem either. 在Windows命令行中也没有问题。 If we use the PowerShellExec Macro 如果我们使用PowerShellExec宏

${PowerShellExec} "our command"

or if we use the NSexec command does not matter. 还是我们使用NSexec命令都没有关系。 We always get the error message that "The access to the path has been denied". 我们总是收到错误消息,“对路径的访问已被拒绝”。 We found out that it might be a problem with the security policy of the powershell. 我们发现,PowerShell的安全策略可能存在问题。 Is there a way to change the security policy in NSIS or is there another way to call the command inside the installer? 是否可以在NSIS中更改安全策略,或者是否可以在安装程序中调用该命令?

Assuming you're testing on systems that only have PowerShell v2 installed, this appears to be a known issue with PowerShell v2 . 假设您正在仅安装PowerShell v2的系统上进行测试,那么这似乎是PowerShell v2已知问题

There are several workarounds mentioned in both the Nullsoft forum and on MS Connect. Nullsoft论坛和MS Connect中都提到了几种解决方法。 The most straightforward solution is to add -InputFormat None to the command line, but that is undocumented. 最直接的解决方案是在命令行中添加-InputFormat None ,但这是未记录的。

Alternately, if it's the execution policy that's throwing you, you can try adding -ExecutionPolicy Bypass to the command line. 另外,如果是执行策略使您-ExecutionPolicy Bypass ,可以尝试在命令行中添加-ExecutionPolicy Bypass

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

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