如何在NSIS中调用PowerShell
发布时间:2020-12-14 05:27:51 所属栏目:Windows 来源:网络整理
导读:我试图在NSIS中运行Power Shell.当我运行NSIS脚本时: !include "x64.nsh"Name "nsExec Test"OutFile "nsExecTest.exe"ShowInstDetails showSection "Output to variable" nsExec::ExecToStack 'powershell -Command " {Import-Module }" ServerManager' Pop
我试图在NSIS中运行Power
Shell.当我运行NSIS脚本时:
!include "x64.nsh" Name "nsExec Test" OutFile "nsExecTest.exe" ShowInstDetails show Section "Output to variable" nsExec::ExecToStack 'powershell -Command "& {Import-Module }" ServerManager' Pop $0 # return value/error/timeout Pop $1 # printed text,up to ${NSIS_MAX_STRLEN} DetailPrint '"ImportModules" printed: $1' DetailPrint " Return value: $0" nsExec::ExecToStack 'powershell -Command "& {Get-WindowsFeature}" Desktop-Experience' Pop $0 # return value/error/timeout Pop $1 # printed text,up to ${NSIS_MAX_STRLEN} DetailPrint '"GetWindowsFeature" printed: $1' DetailPrint " Return value: $0" SectionEnd 当它执行到“Import-Module ServerManager”时,PowerShell启动了(可以在TaskManager进程中看到).但是nsExecTest.exe却被挂了. 我已经google了这个问题,并找到了Java的解决方法. 任何人都有关于NSIS这个问题的想法? 更新: !include "x64.nsh" Name "nsExec Test" OutFile "nsExecTest.exe" ShowInstDetails show Section "Output to variable" ${If} ${RunningX64} ${DisableX64FSRedirection} nsExec::ExecToStack 'powershell.exe "& "Import-Module ServerManager"' Pop $0 # return value/error/timeout Pop $1 # printed text,up to ${NSIS_MAX_STRLEN} DetailPrint '"ImportModules" printed: $1' DetailPrint " Return value: $0" DetailPrint "" ${EnableX64FSRedirection} ${Else} ${EndIf} SectionEnd 解决方法
据我所知,AaronLS的答案对我不起作用,我找到了两个解决这个问题的方法,与PowerShell v2
reported here中的一个错误有关(但从未修复过):
> Upgrade to PowerShell v3 SetOutPath "$pluginsdirNSISTemp" File script.ps1 nsExec::ExecToStack 'powershell -inputformat none -ExecutionPolicy RemoteSigned -File "$pluginsdirNSISTempscript.ps1" ' 使用宏I’ve written here,只需${PowerShellExec}“echo’hello powershell’”. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- window常见事件onload
- windows – 确保在任何给定时间只有1个PowerShell脚本实例正
- 在Windows中从纯C创建一个唯一的临时目录
- windows – 删除和创建目录的奇怪情况
- windows – WinDbg Dr. Watson minidump – 需要最初为安装
- Window Git $git config –global http.proxy警告:http.pr
- windows – 群集和/或Hyper-V副本?
- windows-installer – Visual Studio MSI安装程序
- windows-server-2003 – IIS6:Web站点提供错误的SSL证书
- hp-proliant – HP DL320e Gen8,3TB驱动器,Windows Server
推荐文章
站长推荐
热点阅读