Hello!
In my .onInit function I have the following code:
Function .onInit
${If} $InstDir == ""
StrCpy $InstDir "$PROGRAMFILES64\MyCompany\MyProgram"
${EndIf}
FunctionEnd
and then in section of program I do the following:
SetOutPath "$INSTDIR\"
File /r "${PACKAGE_DIRECTORY}"
It works perfectly when user didn't try to use another installation directory. Suppose he choosed "D:/Programs", then my $INSTDIR becomes "D:/Programs" but not "D:/Programs/MyCompany/MyProgram" as I want.
To be more specific - how to add "/MyCompany/MyName" to user specified folder like NSIS does in its installator?
Can you point me how to handle this?
How to apped subdirectory to user-chosen install directory?
3 posts
So you just copied some code from somewhere without understanding it?
${If} $InstDir == "" in .onInit is how you check if /D= was used on the command line. The NSIS installer does not do this, it just uses the InstallDir attribute. Read about InstallDir and how it handles the final \ in the documentation to understand what the NSIS installer does.
This does not work with the \company\appname scheme though and I would not recommend that you try to implement this because it is just annoying for your users!
And finally, \ is the path separator on Windows and in NSIS, not /.
${If} $InstDir == "" in .onInit is how you check if /D= was used on the command line. The NSIS installer does not do this, it just uses the InstallDir attribute. Read about InstallDir and how it handles the final \ in the documentation to understand what the NSIS installer does.
This does not work with the \company\appname scheme though and I would not recommend that you try to implement this because it is just annoying for your users!
And finally, \ is the path separator on Windows and in NSIS, not /.
Thank you, got it working.