我需要在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
nsExec::ExecToStack 'powershell.exe -command "& "Import-Module ServerManager"'
重试一下。