Problem with detecting invalid directory
Using version 2.0.b3 of NSIS and the MUI, how do I validate the installed directory and why is GetInstDirError an invalid command?
11 posts
It might not work though. Even in the latest docs it does not say under SetOutPath that the error flag is set if SetOutPath fails...ClearErrors
SetOutPath $INSTDIR
IfErrors 0 +3
MessageBox ...
Abort
So basically, this will write a file to the current path if the path exists to check if the path is writable. It won't try and create the path.
Function .onVerifyInstDir
IfFileExists "$INSTDIR\*.*" 0 End
Push $R0
ClearErrors
FileOpen $R0 "$INSTDIR\try.tmp" w
FileWrite $R0 ""
FileClose $R0
Pop $R0
IfErrors +3
Delete "$INSTDIR\try.tmp"
Goto End
MessageBox MB_OK|MB_ICONEXCLAMATION "Path is not writable, please enter a new path!"
Abort
End:
FunctionEnd