Archive: nsExec::Exec exit error problem


nsExec::Exec exit error problem
I am writing out a VBScript, which on execution creates a virtual directory. This is detailed at http://nsis.sourceforge.net/Setting_...tual_directory

My problem is when a virtual directory can not be created, I would like the user to try again with another name. But I can't seem to test when the script exits with error.

code snippet:

ClearErrors
nsExec::Exec /TIMEOUT=20000 '"$SYSDIR\cscript.exe" "$TEMP\createVDir.vbs"'

IfErrors success
MessageBox MB_OK "Virtual directory $serverVirtualDir could not be created!"
goto finish
end of vbscript:
If (E******mber <> 0) Then
WScript.Quit (E******mber)
So as far as I can see, if script fails to create virtual directory, the vbscript should exit with an error, and IfErrors should be pick this up.

Can anyone tell me what I am not doing please?[

nsExec pushes result to NSIS stack, so use Pop command instead of IfErrors to get exit code. Like this (from test.nsi)


nsExec::ExecToLog '"${NSISDIR}\makensis.exe" /CMDHELP'
Pop $0 # return value/error/timeout
; or
nsExec::ExecToStack '"${NSISDIR}\makensis.exe" /VERSION'
Pop $0 # return value/error/timeout
Pop $1 # printed text, up to ${NSIS_MAX_STRLEN}