Archive: How to warn when dest directory exists?


How to warn when dest directory exists?
When installing, if the dest directory exists, is there any easy way to promp a warning dialog to confirm that like the one in Inno setup?
Should I have to do this by myself to code it?


!define MUI_PAGE_CUSTOMFUNCTION_LEAVE DirectoryLeave
!insertmacro MUI_PAGE_DIRECTORY

Function DirectoryLeave

IfFileExists "$INSTDIR\*.*" 0 +3
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"The destination folder already exists. $\r$\n \
Would you like to use it anyway?" MB_OK +2
Abort

FunctionEnd


-Stu

Thanks. Very useful code.

But why
IfFileExists "$INSTDIR\*.*" 0 +3
?
Maybe it should be
IfFileExists "$INSTDIR" 0 +3
is it OK?

Even the dest directory is empty, I would like to confirm too.


The correct way to check if a folder exists is to use \*.* on the end. Otherwise the test will pass if $INSTDIR is a file path and not a directory path.

-Stu