Socrate
21st December 2007 17:12 UTC
Exclude folders at install
Hello
I have made my installer with NSIS and the client doesn't want to the user can install my application on the Desktop (for example).
I'm a newbie with NSIS.
I create a MUI_PAGE_DIRECTORY where the user can select the installation path. But I want to show him a message box whihc tell him that he doesn't allow to install the application on the Desktop if he has decided to do it.
Which method can I use to solve this problem ?
Thanks for all your replies
Red Wine
21st December 2007 19:20 UTC
Here's some clue to start over,
outfile test.exe
InstallDir `$PROGRAMFILES\My Application`
page directory `` `` dirleave
page instfiles
section
sectionend
Function dirleave
Push "$INSTDIR"
Push "$DESKTOP"
Call StrOutOfStr
Pop $R0
StrCmp "$R0" "error" proceed
MessageBox MB_ICONSTOP|MB_OK \
"Installation on DESKTOP is not allowed, choose another directory"
Abort
proceed:
FunctionEnd
Function StrOutOfStr
Exch $0
Exch
Exch $1
Push $2
Push $3
Push $4
Push $5
StrCpy $3 "0"
StrLen $4 "$0"
StrLen $5 "$1"
IntCmp $4 $5 0 0 _err
Intop $5 $5 - $4
_start:
StrCpy $2 "$1" $4 $3
StrCmp "$2" "$0" _done
IntCmp "$3" "$5" _err
Intop $3 $3 + 1
Goto _start
_err:
StrCpy $2 "error"
_done:
StrCpy $0 "$2"
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Exch $0
FunctionEnd
{_trueparuex^}
21st December 2007 21:10 UTC
And here's a different approach...
...
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE MyDirLeave
!insertmacro MUI_PAGE_DIRECTORY
...
Function MyDirLeave
Push $0
StrLen $0 $DESKTOP
StrCpy $0 $INSTDIR $0
StrCmp $0 $DESKTOP 0 proceed
MessageBox MB_ICONSTOP|MB_OK \
"Installation on DESKTOP is not allowed, choose another directory"
Abort
proceed:
Pop $0
FunctionEnd