Archive: Any way to change installation dir during install?


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


Take a look here.


Thanks! Holy Moses, I didn't even know that reference existed. :D


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.


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.

There is no callback for the next button...


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

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.


Originally posted by kichik
There is no callback for the next button...
Well, I feel stupid. That would be a nice feature though :)

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

.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