Archive: nsisStartMenu Plugin : ensure your shortcuts order !


nsisStartMenu Plugin : ensure your shortcuts order !
nsisStartMenu Plugin Homepage

Presentation

nsisStartMenu is a small NSIS plugin that that will help you ensure a given order of shortcuts in Start Menu

You can typically use to ensure that the shortcut for your main program executable appears first and the shortcut for the uninstaller appears last, in the folder you're creating under Windows' Start Menu

Usage
The following is taken from the readme file in the downloadable zip file:


nsisStartMenu::RegenerateFolder "<folder name>"

<folder name> is the name of your folder under the $SMPROGRAMS folder
It should not contain the prefix $SMPROGRAMS\, but it can contain backslashes if
you're working on a subfolder

This will force an update of the state of the corresponding shell menu (just as if
the user has displayed the menu)
=> All deleted entries (since the last state of the menu) will be pruned from the
menu
=> All new entries (since the last state of the menu) will be added at the end of
the menu in alphabetical order

Return Value
------------

nsisStartMenu returns an integer status on the top of the stack
Possible status are:
0: Failure
1: Success


Download
nsisStartMenu Plugin Homepage

ZIP archive contains the plug-in DLL, as well as documentation, sample script and a LIB file for C++ programmers

I wonder why my plugin doesn't have much success ?
I spent so many hours trying to understand how Windows works things out regarding the start menu shortcuts.
I was proud to have found a clean solution to a problem that seems so common to most installers..

So please tell me :
- don't you register start menu shortcuts in your installers ?
- don't you care about the order of these shortcuts ? like it doesn't bother you having "Uninstall" appearing first sometimes ? (especially in language like French "désinstaller" is likely to be often first)
- or maybe you don't add the "uninstall" shortcut to the start menu and let the user go through "add/remove program" ?
- does your installer registers several shortcuts in the Start Menu ? like help files or secondary programs ?

For those who tried my plugin, don't hesitate to give me some feedback

Thanks !


Just released version 1.1 which supports Unicode-NSIS
through nsisStartMenu::RegenerateFolderW "<folder name>"

http://wiz0u.free.fr/prog/nsisStartMenu/


I am just about to try your plugin now.

In the meantime I will say THANK YOU! I was getting so frustrated with my shortcuts showing up in what seemed like a totally random order. If this works, you are my hero!


Didn't seem to work. It always errors.

Here is the code:


CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
SetOutPath "$INSTDIR\path"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\link.lnk" "$INSTDIR\path\file.exe"
nsisStartMenu::RegenerateFolder "$STARTMENU_FOLDER"
Pop $0
IntCmp $0 0 0 noError noError
MessageBox MB_OK "Foiled."
noError:


Don't know if this would affect it, but currently (while testing) that link points to nothing. The file doesn't exist. Also, all the shortcut commands are wrapped by the MUI macros:

!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
!insertmacro MUI_STARTMENU_WRITE_END

are you using Unicode-NSIS ?
what does $STARTMENU_FOLDER contain ?
are you using SetShellVarContext current or all ?
does it fail if the shortcut points to an existing file ?


Yes its Unicode-NSIS
$STARTMENU_FOLDER contains a string defining the start menu folder name. In this case it was "Product Version".
I am doing nothing with SetShellVarContext.
Haven't tried it with a valid link yet.


for Unicode-NSIS, you should use
nsisStartMenu::RegenerateFolderW
instead of
nsisStartMenu::RegenerateFolder


Works like a hot damn! Thank you, sir!


Originally posted by Wizou
I wonder why my plugin doesn't have much success ?
I spent so many hours trying to understand how Windows works things out regarding the start menu shortcuts.
I was proud to have found a clean solution to a problem that seems so common to most installers..
i'm often annoyed by unsorted startmenus, so i wrote a script that just orders it on every startup. however, i wouldn't force a setting on a different user, just because i prefer it. i'm thinking of adding it, if it doesn't add to much size.. but only with a dialog, which asks for confirmation first. otherwise people might skip your product just because of that installer behaviour.

just wanted to point this out, of course a lot of commands alone can do damage, it's all about the right combination of commands :)

I just gave your plugin a try and it seems to work fine.
Guess I'll keep it in my installer. Thanks!

One question though:
Which OS does it support? Will it work on Vista too?


@Yathosho: My plug-in only orders the start menu subdirectory of your choice (typically the one your installer is creating), not the whole start menu. And it can't place new shortcuts in front of existing ones.
So it can only be useful for building up your application's submenu so that your shortcuts appears in a useful order.

@LoRd_MuldeR: As noted in the ReadMe file, I've tested it under Windows XP but it should be compatible with Windows 2000, XP and more recent. However, on Vista, the new start menu doesn't allow the user (or an installer) to choose a customized order for shortcuts. So I can't do anything for it. In any case, you can still call the plug-in, it won't do any harm and gracefully return an error code if it didn't work.

PS: I just realized that you could choose the old start menu behaviour in Vista, and it seems like nsisStartMenu doesn't work with it. I will check that out and release a compatible version of nsisStartMenu soon.

Thanks for your feedback :)


Originally posted by Wizou
However, on Vista, the new start menu doesn't allow the user (or an installer) to choose a customized order for shortcuts. So I can't do anything for it. In any case, you can still call the plug-in, it won't do any harm and gracefully return an error code if it didn't work.
Thx, that's what I needed to know!

First, thanks a lot for this plugin, I could not find any documentation in MSDN about this matter, so I am happy I have found this plugin.

Positioning one item as first or as last functions fine, but I want to have *all* menu items positioned in the order they were created. It is not much clear what the RegenerateFolder actually does, so I do not know whether calling it after each inserted item would bring the desired effect (I will test it anyway).


Originally posted by zdenek_martinek
First, thanks a lot for this plugin, I could not find any documentation in MSDN about this matter, so I am happy I have found this plugin.

Positioning one item as first or as last functions fine, but I want to have *all* menu items positioned in the order they were created. It is not much clear what the RegenerateFolder actually does, so I do not know whether calling it after each inserted item would bring the desired effect (I will test it anyway).
1. Delete the folder (if existing)
2. Create a new folder
3a. Create new Shortcut in that folder
3b. Run "RegenerateFolder" on the folder
3c. If more shortcuts then goto 3a, else skip
4. You are done!

Thanks, now it works much better! Anyway, I still have a partial problem: the shortcuts are now placed as I need, but when there are subdirectories (=submenus), they are still sorted alphabetically, even if after each directory creation I call RegenerateFolder for its parent.


Originally posted by zdenek_martinek
Thanks, now it works much better! Anyway, I still have a partial problem: the shortcuts are now placed as I need, but when there are subdirectories (=submenus), they are still sorted alphabetically, even if after each directory creation I call RegenerateFolder for its parent.
Make sure you RegenerateFolder also *before* creating the *first* subfolder.

Thanks for helping people out, LoRd_MuldeR :)

Just to let you know my findings: On Vista, the new start menu *does* in fact allow for a custom order if the user has uncheck the "sort Programs menu by name" in the Start menu Properties dialog.
This is not a well-known option so I doubt many users have changed it (checked by default), but I'm working on having nsisStartMenu also function properly with it.


Originally posted by LoRd_MuldeR
Make sure you RegenerateFolder also *before* creating the *first* subfolder.
Now it works, I also had a small bug in my code. Thanks again for this valuable plugin! :up:

Originally posted by zdenek_martinek
Thanks again for this valuable plugin! :up:
You're welcome :)