Hello there,
I Searched the forum, but couldn't find the how to. I am a little new to NSIS. So please excuse if it's a very simple question.
I have an app that comes with several modules, each can be installed separately but if there is one of the modules already installed the other ones *HAVE* to be in the same folder, so I better disable the Destination Folder page or dialog.
I have used the NSIS examples and this forum to build the script, but I can't figure out how can I check if the InstallDirRegKey is present and then don't let the user mess with install dir.
Thanks in advance,
Cërf.
Disabling "Destination Folder" page
6 posts
I found something Here but I don't think it performs the check about installRegKey being present.
Use ReadRegStr.
E.g.
-Stu
E.g.
Edit: If you want to disable the directory field only, then your code would be different...
!define InstallDirRegKey '"HKCU" "Software\MyApp" "InstallDir"'
InstallDirRegKey ${InstallDirRegKey}
!define MUI_PAGE_CUSTOMFUNCTION_PRE DirectoryPre
!insertmacro MUI_PAGE_DIRECTORY
Function DirectoryPre
ReadRegStr $R0 ${InstallDirRegKey}
StrCmp $R0 "" +2
Abort # Skip page
FunctionEnd
There's code in there to re-enable them again just in case.
!define InstallDirRegKey '"HKCU" "Software\MyApp" "InstallDir"'
InstallDirRegKey ${InstallDirRegKey}
!define MUI_PAGE_CUSTOMFUNCTION_SHOW DirectoryShow
!insertmacro MUI_PAGE_DIRECTORY
Function DirectoryShow
FindWindow $R1 "#32770" "" $HWNDPARENT
ReadRegStr $R0 ${InstallDirRegKey}
StrCmp $R0 "" NoDisable
GetDlgItem $R2 $R1 1019 # Dir box
EnableWindow $R2 0
GetDlgItem $R2 $R1 1001 # Browse button
EnableWindow $R2 0
Goto End
NoDisable:
GetDlgItem $R2 $R1 1019 # Dir box
EnableWindow $R2 1
GetDlgItem $R2 $R1 1001 # Browse button
EnableWindow $R2 1
End:
FunctionEnd
-Stu
Hey there Stu,
Thanks for the reply!
I'm using the "skip" code, but now I am facing the embarrasing problem of not knowing how to assing a value to $INSTDIR when no other installation have been detected.
Thanks again!
Cërf.
Thanks for the reply!
I'm using the "skip" code, but now I am facing the embarrasing problem of not knowing how to assing a value to $INSTDIR when no other installation have been detected.
Thanks again!
Cërf.
StrCpy $INSTDIR "C:\Your\Default\Path"
?
?
Use InstallDir as always, so if there is not other installation and the directory page is going to be visible, the browse field would prompt users with what you have entered in InstallDir.