Archive: Issues related to Start menu shortcuts orders during installation


Issues related to Start menu shortcuts orders during installation
Purpose of my Installer is:
1) Create a folder by name PosPlus (default c:\PosPlus)
2) Create a sub-folder by name 'samples' in c:\posPlus
This 'samples' sub-folder contains a few application related text files.
These text files are also copied in this sub-folder.
3) Copy/extract pos.exe to c:\PosPlus
4) Copy/extract databack.exe to c:\PosPlus
5) Copy/extract uninst.exe to c:\PosPlus
6) Copy/extract PosPlus.chm to c:\PosPlus
7) Create desktop shortcut for main application:pos.exe
8) Create shortcut in Windows Start Menu->Program->
in following order:
Start Menu-->Program-->Pos Plus-->Pos Plus
-->Backup Manager
-->Pos Manual
-->Samples
-->Uninstall

My problem is that the installer is smoothly installing all the steps mentioned-above,
but the shortcuts in the start menu for Pos Plus are not comming as per my above order.
The 'Uninstall' shortcut is comming as the first option and the others are also not in
the same order as shown above.

One more thing I want to do is that I want to show my sub-folder Samples and its contents in
this start menu. For this I added this line my script :

CreateDirectory "$SMPROGRAMS\PosPlus\Samples"

This helped me in showing the folder "Samples"(empty). Yes it is showing 'empty' although
it contains many text files inside it.

What I want :

Start Menu-->Program-->Pos Plus-->Pos Plus
-->Backup Manager
-->Pos Manual
-->Samples---->t1.txt(shortcut)
---->t2.txt(shortcut)
--->....... and so on when the user clicks samples
and when he clicks t1.txt then that file opens
up in notepad.
-->Uninstall

A fraction of script is given below to understand my issue:

Section "Complete" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "AppFolder\pos.exe"
CreateDirectory "$SMPROGRAMS\PosPlus"
CreateDirectory "$SMPROGRAMS\PosPlus\Samples"
;CreateShortCut "$SMPROGRAMS\PosPlus\Samples" "$INSTDIR\Samples"
CreateShortCut "$SMPROGRAMS\PosPlus\Pos Plus .lnk" "$INSTDIR\pos.exe"
CreateShortCut "$SMPROGRAMS\PosPlus\Backup Manager.lnk" "$INSTDIR\databack.exe"
CreateShortCut "$DESKTOP\Pos Plus.lnk" "$INSTDIR\pos.exe"
File "AppFolder\databack.exe"
File "AppFolder\Format.txt"
File "AppFolder\PosPlus.chm"
CreateShortCut "$SMPROGRAMS\PosPlus\Pos Manual.lnk" "$INSTDIR\PosPlus.chm"
SetOutPath "$INSTDIR\Samples"
SetOverwrite try
File "AppFolder\Samples\T1.TXT"
File "AppFolder\Samples\T2.TXT"
File "AppFolder\Samples\T5.TXT"
File "AppFolder\Samples\T7.TXT"
File "AppFolder\Samples\T8.TXT"
File "AppFolder\Samples\T9.TXT"
File "AppFolder\Samples\T10.TXT"
File "AppFolder\Samples\T11.TXT"
File "AppFolder\Samples\T12.TXT"
File "AppFolder\Samples\T13.TXT"
File "AppFolder\Samples\T17.TXT"
File "AppFolder\Samples\T18.TXT"
File "AppFolder\Samples\T19.TXT"
File "AppFolder\Samples\T20.TXT"
File "AppFolder\Samples\Format.TXT"
SectionEnd

Section -AdditionalIcons
;WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
;CreateShortCut "$SMPROGRAMS\PosPlus\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\PosPlus\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\PosPlus.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\PosPlus.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd


Thanks in advance,
With regards,
Swapan Das


As iceman_k has already mentioned in your previous thread, Windows manages the order of the shortcuts in the Start menu sorting them by name. You cannot sort it through the installer. The only thing you can do is place a + in front of the main shortcut name to make sure that it's always at the top.

-Stu


Dear Stu,
Thanks for the reply.
You said windows manages the shortcuts in the Start menu by sorting them name-wise. Then why my Uninstall shortcut will appear at the top:
Start Menu-->Program-->Pos Plus-->Pos Plus
-->Backup Manager
-->Pos Manual
-->Samples
-->Uninstall
And Please note the shortcuts of NSIS
--->Contrib -->AdvSplash Readme
-->...and all the files
shortcuts.
Similarly I want to show my subfolder "samples" (which is
under my main folder PosPlus) and shortcuts for all the
text files inside the "samples" folder in the same fashion as startmenu->Programs->NSIS->Contrib->AdvSplash Readme.

Please help me. Its very urgent for me.

With regards,
Swapan das


Windows does not sort alphabetically by default.
The user has to manually specify alphabetical sorting.
Windows uses some internal logic to sort the menu items.

Edit
Windows uses the following registry value to store the order of the menu items.
Key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu\Programs\XYZ
Value: Order

where XYZ is your program group.

The Order registry value is REG_BINARY, so if you can decode it then you can manually rearrange the order of the items.


i solved the problem by first installing my application, then changing the order manualy. Next I copied the "Order" value, which windows created and used it in my nsi file. e.g.:
WriteRegBin HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu\Programs\XYZ" "Order" 00890888003.....

it works :)


That's a good solution.

Stu


Thanks rutsche for replying to my this old thread. You did a brilliant 'trick'. Since I'm pre-occupied with many other things now, hope to test it in near future.

Regards,
Swapan


check out my new nsisStartMenu Plugin
(no registry trick, the work is done by Windows Shell)


My plugin works by forcing the Shell to do a premature update of your startmenu folder's menu, so that you can be sure that the shortcuts you created before the call will show up before the shortcuts you create after the call.

Note: the nsisStartMenu.dll exports a function that can be used outside NSIS installers


Thanks Wizou for coming to my this old thread and giving your solution for it.

Anybody who has applied above solutions to resolve this issue do let me know if its working fine and the windows version he/she is using while testing for this issue. Be specific you applied which solution, rutsche's or Wizou's.

Currently I'm into different things, so unable to test these solutions for this issue which troubled me a lot during my initial days of installer creation.

Regards,
Swapan
[ps.:how's everybody there, esp. RedWine?!]


If you only want your shortcuts in the start menu to display in alphabetical order, then you can just delete the key referring to your products entry.

The next time the start menu shortcuts are accessed, they will be displayed alphabetically.

Example.

DeleteRegKey "Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu\Programs\XYZ"