- NSIS Discussion
- Any way to change installation dir during install?
Archive: Any way to change installation dir during install?
HelluvaEngineer
26th November 2002 18:51 UTC
Any way to change installation dir during install?
Hi guys.
I have a request for functionality in my installer to warn the user if the requested install directory does not exist, and give them the option to designate another directory if they want.
Off the top of my head, I cannot think of any way to implement this. A warning is easy enough, but how do I give them the option to go BACK and set a new dir?
tia
-HE
rainwater
26th November 2002 20:57 UTC
Take a look here.
HelluvaEngineer
26th November 2002 21:05 UTC
Thanks! Holy Moses, I didn't even know that reference existed. :D
HelluvaEngineer
26th November 2002 22:11 UTC
One problem. That callback is called every time I enter a letter. If a user wants to manually key in a new directory, the warning popup is launched after each keypress!
What I want to do is check the dir after they select next, and give them a chance to go back.
rainwater
26th November 2002 22:27 UTC
Originally posted by HelluvaEngineer
One problem. That callback is called every time I enter a letter. If a user wants to manually key in a new directory, the warning popup is launched after each keypress!
What I want to do is check the dir after they select next, and give them a chance to go back.
Yes. I should of told you that. If you are using NSIS 2.x you can add a callback to the Page command that is called when the user hits next. And that callback can do the verification.
kichik
27th November 2002 14:55 UTC
There is no callback for the next button...
HelluvaEngineer
27th November 2002 15:20 UTC
Any ideas on how to handle this, then?
I upgraded to 2.0a4, changed a couple of things, and tried to recompile. It wrote a file, but kicked out a vague error.
Processed 1 file, writing output:
Removing unused resources... Done!
Finding icons offsets for uninstaller...
generate_unicons_offsets: number of icons doesn't match -- failing!
Error - aborting creation process
kichik
27th November 2002 15:33 UTC
Alpha 4 is a very old version. Please use the latest CVS version if you wish to use NSIS 2 (download instructions in the FAQ).
You got that error because you didn't use the same icon structure for the installer and the uninstaller.
With NSIS 1.98 you could follow the page numbers with the .onNextPage and when you get to the number of the directory page you could test to see if $INSTDIR has spaces in it and only then let the user skip the page.
rainwater
27th November 2002 16:22 UTC
Originally posted by kichik
There is no callback for the next button...
Well, I feel stupid. That would be a nice feature though :)
HelluvaEngineer
27th November 2002 16:27 UTC
Thank you much. That is definitely the way to handle it. For future reference, here's the script I used:
Function .onNextPage
StrCmp $0 3 "" next
IfFileExists $INSTDIR next ""
MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON1 \
"The directory you specified does not exist.$\n \
Do you want the installer to create it?" IDYES next
Abort
next:
IntOp $0 $0 + 1
FunctionEnd
Joost Verburg
27th November 2002 16:40 UTC
.onNextPage has been removed from the latest NSIS 2 version, because of the new page system. You can verify the directory in the Page function of the instfiles page.
Alpha 4 is a very old version. Download the latest snapshot at http://nsis.sf.net