Archive: Prompting for a destination folder for shortcuts


Prompting for a destination folder for shortcuts
In most installers, the user has the option to override the default folder where the shortcuts get placed by displaying a list of all the available folders under Start->Programs.

is there any way to accomplish this in NSIS? I can't find any code for this, are there maybe some DLL extensions for this?

It's not a critical feature, but one of those "nice to have" things...


You could try to build this with InstallOptions. The problem: we cannot retrieve the directory structure of the StartMenu using NSIS. You would need to build a DLL for that. The output of this DLL should be the argument of a "DropList" or "ListBox" in InstOpts.

It's possible, but not with standard NSIS code.

Good luck,
-Hendri.


Couldn't the folder listing be accomplished using FindFirst, FindNext and FindClose using some kind of recursive function. To identify folders you should use IfFileExists. Write all the folders you find into the ini file and it is ready to be displayed.


Hmmm, yes, could be used of course, but there will be an additional problem (as we also encounter with InstallShield and Wise). Since for example in Win2K every user has its own path for the startmenu. Some users (like me :)) just collect all shortcuts into their own startmenu and clearing the "All user" startmenu. So this is empty, no folders found. So we need some additional programming first to ask the user which folder ("User" or "All users") to use and then we can search that path and display the ini.

Concluding, possible (contrary to my first belief, please do not punish me, I cannot be almighty or all-knowing).

Good luck,
-Hendri.


I am fighting enough with InstallOptions :)

Let me skip this functionality altogether then...the users can move it wherever they want later...


Zaraza,

I'll post an example script tomorrow. Check this thread again then.

-Hendri.


hmmm... here is something I wrote a while ago before InstallOptions came out I think (or at least before it was made into a dll). As it is, it isn't particularly impressive (but now works, I think the last time I posted a link, I forgot to include the actuall DLL :)), but someone could use the code and hack it up a bit.

I can't remember what it does for WinNT start menus..

(attached).


Actually, looking over the source code for it, it is extremely ugly. I cant believe I ever wrote that!

A couple of notes;
Check the dll was loaded (I haven't had time to check, but I presume the error flag is set)
** request; can dll plugins get a ptr to the error flag/
Check the dlg was created (by popping, checking [and pushing, if it does not equal 0]).
And no, it is not necessary to extract and delete the dll and resource script everytime it is used.. only at the onInit, abort etc.
If the dlg was created, make sure you dealloc.


Here's the script I promised to upload. It uses MultIni4 by Dave Laundon (and a bit by me). See this thread. The pity is that the components of a CustomPage cannot interact. Now people need to retype a selected dir if they want to create a subdir. But it works.

Good luck, greetz,
-Hendri.


Sorry, forgot the actual script...

Here's the attachment.

[edit #1]
I found a bug in the script: forgot to Pop $0 before returning if the user did not type or select a dir. Solved now.
[/edit]

[edit #2]
The code by pjw62 solves the problem of non-interacting components and can be implemented in multini4, but to be honest, the setting up the .res file might be a problem.
[/edit]

-Hendri.


If creating resource files is a problem for people with out the MS Dev studio/resource compiler etc, I think Borland has a free 'resource workshop' available.

ALso, I was thinking that a better way to implement additional pages etc would be to still use resource files (they are nice and easy to layout and design) would be to have it is as an optional #define on compiling makensis, then we could do things like going backwards and forwards, checking etc more cleanly with callbacks.


PJW62,

I searched the Borland site, I couldn't find a free resource workshop. Please post a hyperlink to it so everyone can start using your nice utility.

Thanks, greetz,
-Hendri.


http://linux20368.dn.net/protools/utilities.htm

or http://protools.cjb.net/ if the link above doesn't work

resource workshop is a 16 bit app, wouldn't resource hacker work also?


Well, I tested the construction with .res files, but I'm not happy with the results. It seems that the control loads the startmenu of the current user only, so we cannot choose to install shortcuts for all users with this control.
To install for all users, we cannot ask to choose a dir. So we're back where we started. In that case, use my solution in NSIS. It has a minor drawback, but it is compatible to multiple users.

Another drawback is that it doesn't work properly from functions (so implementation in MultIni4 becomes impossible). I couldn't yet figure out why, but when clicking cancel in the ExDlg, .onUserAbort isn't even called. So 'dealloc' and deletion of the dll becomes impossible. (So files remain on harddisk, installer remains resistent as a process...) It works from a section quit well, but then we cannot integrate it in the 'first part of the installer', where user input is requested.

Maybe pjw62 can solve these bugs for us?

Check my code, but be warned! Do not compile and run the script!

Good luck with it, greetz,
-Hendri.


Yes, thanks for pointing that out Smile2Me.. I think I need to sort out this bug before anyone uses this.

I've got a Nuclear Physics and Cosmology exam tomorrow, so I dont think I'll be looking at it tonight ;)


Ok, we'll wait for it. If this bug is solved, it would be a great contribution! Please try your new version with my script and you will easily see if it works.

Good luck with your exam.

Greetz,
-Hendri.


Sunjammer has created a modified InstOpts which allows for communication of components. It is called targetting. So, the problem described above has been solved and this is now a fully working demo. Please remind (as you can find in the zip too) that the modified IO is a beta version!

Please refer to the NSIS Database to keep your script up to date, since we expect some nice modifications of IO to come in the near future.

Have fun, greetz,
-Hendri.