Destination Folder
How can I dynamically set MUI_PRODUCT_DIR?? I want to be able to put anything in destination folder.
Any help is appreciated.
Archive: Destination Folder
Destination Folder
How can I dynamically set MUI_PRODUCT_DIR?? I want to be able to put anything in destination folder.
Any help is appreciated.
You don't need define anything. Use the $INSTDIR variable. This is the default variable used to install program files in, contains the install folder written by the user.
To put files in the folder written in $INSTDIR var, use:
SetOutPath $INSTDIR
SetOutPath $INSTDIR\SubFolder
I should say how can I override
InstallDir "$PROGRAMFILES\${MUI_PRODUCT_DIR}"
so that "Destination Folder" would show up with a value I have in registry.
You could scrap MUI_PRODUCT_DIR define, and use
StrCpy $INSTDIR "C:\whatever"
Or
StrCpy $INSTDIR "C:\whatever${MUI_PRODUCT_DIR}"
-Stu
OK but then how could I make it to show up in the Destination folder? This code can not be put outside a Section.
Place in Function .onInit
-Stu
It worked
Thanks a bunch!! I put my function call in the init function and it worked...for anyone's reference here it is...
Function installDirectory
; set $INSTDIR to registry value if previous installation detected
ReadRegStr $0 HKCU "SOFTWARE\Sandvine" "Installed"
StrCmp $0 "" NotPresent Present
NotPresent:
WriteRegStr HKCU "SOFTWARE\Sandvine" "Installed" "1"
WriteRegStr HKCU "SOFTWARE\Sandvine" "InstalledDirectory" "$INSTDIR"
StrCpy $INSTDIR "$PROGRAMFILES\${MUI_PRODUCT_DIR}"
Goto Done
Present:
ReadRegStr $0 HKCU "SOFTWARE\Sandvine" "InstalledDirectory"
StrCpy $INSTDIR "$0"
Done:
FunctionEnd
Wow, everyone are speaking faster today! Three persons posting in the same time!
You don't need that StrCpy in there if used like this:
InstallDir "$PROGRAMFILES\${MUI_PRODUCT_DIR}"
Function InstallDirectory
; set $INSTDIR to registry value if previous installation detected
ReadRegStr $0 HKCU "SOFTWARE\Sandvine" "Installed"
StrCmp $0 "" NotPresent Present
NotPresent:
WriteRegStr HKCU "SOFTWARE\Sandvine" "Installed" "1"
WriteRegStr HKCU "SOFTWARE\Sandvine" "InstalledDirectory" "$INSTDIR"
Goto Done
Present:
ReadRegStr $0 HKCU "SOFTWARE\Sandvine" "InstalledDirectory"
StrCpy $INSTDIR "$0"
Done:
FunctionEnd
I was also thinking that maybe you should write the install directory and Installed 1 to the registry after installation.
The user may quit and not install the software, though on re-run it will assume that the installation has already taken place.
-Stu
Good point. I will change the code to take care of that scanario ...effectivelly write to registry after all the files have been copied for some other section.
No, use inside .onInstallSuccess Function.
The code will then be called when the user clicks the Finish button.
-Stu
Hmmm... there is a much easier way to handle the situation of figuring out an install dir while defaulting to whatever was used by an existing installation. :D
Just take a look at both the InstallDir and InstallDirRegKey documentation - the NSIS guys put some effort into solving this particular problem, since it is so common.
This whole mess can usually be handled by something like this:
InstallDir "$PROGRAMFILES\RFtpPRO"
>InstallDirRegKey HKCU "Software\RHpS\RFtp\Settings" "AppFile"
The "InstallDir" sets up your default, and the "InstallDirRegKey" attempts to override it if there is already a path set in whatever reg entry you tell it to look in... note that it is smart, and if the the reg entry has a path to an .exe file, the filename will be stripped, leaving only the directories.Ack, the backslashes got removed by the "PHP" quoting. Sigh. Here is what that should look like, if anyone was confused:
InstallDir "$PROGRAMFILES\RFtpPRO"
InstallDirRegKey HKCU "Software\RHpS\RFtp\Settings" "AppFile"
Use [ code] [/code ]
-Stu
Or when using the [PHP ] and [/PHP ] (without that space) use two insteed of one "\".
In Example:
[PHP ]StrCpy $INSTDIR "C:\\Folder\\SubFolder"[/PHP ]