Skip to content
⌘ NSIS Forum Archive

Write Access in $INSTDIR ?

4 posts

torpark#

Write Access in $INSTDIR ?

How do I run a function to check if the user has write access to $INSTDIR, on leaving MUI_PAGE_DIRECTORY ?

I have the function, I'm just not sure how to call it and don't want to create a custom page.
Afrow UK#

!include LogicLib.nsh

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE DirectoryPageLeave
!insertmacro MUI_PAGE_DIRECTORY

Function DirectoryPageLeave
ClearErrors
FileOpen $R0 $INSTDIR\temp.tmp w
FileClose $R0
${If} ${Errors}
MessageBox MB_OK|MB_ICONSTOP "Path $INSTDIR is write protected!"
Abort
${EndIf}
FunctionEnd
Stu
kichik#
Better use "a" instead of "w" in case the file already exists. A temporary filename with GetTempFileName might be even better.