Lenge
2nd October 2007 09:47 UTC
Ensure that the install directory does not exist
Hello world,
I want my Modern UI installer to only accept an install directory that does not yet exist. How can I achieve this? I understand that I can set a pre-function before the InstFiles page like this:
...
!define MUI_PAGE_CUSTOMFUNCTION_PRE InstFiles_pre
!insertmacro MUI_PAGE_INSTFILES
...
Function InstFiles_pre
IfFileExists $INSTDIR\*.* exist noexist
exist:
MessageBox MB_OK "$INSTDIR\*.*$\nalready exists."
# TODO Go back to InstFiles page
noexist:
FunctionEnd
But how can I go back to the InstFiles page if the test fails?
Anders
2nd October 2007 11:38 UTC
Its probably better to do the check when the user leaves the directory page, if not, http://nsis.sourceforge.net/Go_to_a_NSIS_page might be able to help
Lenge
2nd October 2007 12:12 UTC
You're right, I changed the function to ..._LEAVE before the directory page. Yet still, I need to prevent going forth to the next page from within the function (so that the user can select a different install directory).
I will try the "RelGotoPage" function you suggested, but what makes me doubt a bit is that it says:
Use it only on normal functions, the ".onUserAbort" callback function (w/o MUI) or the !define MUI_CUSTOMFUNCTION_ABORT "Function" (w/ MUI) (see more information at the bottom of the page).
I fear it could have unintentional side effects when used wihtin the MUI_PAGE_CUSTOMFUNCTION_... functions.
Anders
2nd October 2007 13:16 UTC
if you use Abort in the leave function for a page, it will not got to the next page
Lenge
2nd October 2007 13:36 UTC
Abort works.
Thank you very much!