首页 新闻 会员 周边

NSIS如何调用PowerShell

0
悬赏园豆:20 [已关闭问题] 关闭于 2014-02-26 17:45

我需要在Server2008R2上,用NSIS调用powershell来判断Desktop-Experience是否已安装,如果没有安装,则安装它并重启。我做了一个测试程序,在第一步Import-Module时就出错: 
!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 
错误信息为“Access to the path is denied”。请问这是什么原因呢? 
我在stackoverflow上的问题链接http://stackoverflow.com/questions/13391340/how-to-call-powershell-in-nsis 

金石开的主页 金石开 | 初学一级 | 园豆:159
提问于:2012-11-15 16:02
< >
分享
所有回答(1)
0

nsExec::ExecToStack 'powershell.exe -command "& "Import-Module ServerManager"'

重试一下。

LarryIsTaken | 园豆:208 (菜鸟二级) | 2015-06-08 17:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册