Archive: Setting Default Start Menu Folder From Registry


Setting Default Start Menu Folder From Registry
  Just a note for people who wish to read in the value of the selected start menu folder from previous installs and maybe a suggestions for the Modern UI folks, I've changed Function {$SETSTARTMENU} in Contrib/Modern UI/System.nsh to the following:


  Function "${SETSTARTMENU}"


!insertmacro MUI_HEADER_TEXT $(MUI_TEXT_STARTMENU_TITLE) $(MUI_TEXT_STARTMENU_SUBTITLE)
ReadRegStr ${MUI_TEMP1} HKCU "Software\${MUI_PRODUCT}" "Start Menu Folder"
StrCmp "${MUI_TEMP1}" "" +4
StartMenu
::Select /noicon /autoadd /text "$(MUI_INNERTEXT_STARTMENU_TOP)" /lastused "${MUI_STARTMENU_VARIABLE}" /checknoshortcuts "$(MUI_INNERTEXT_STARTMENU_CHECKBOX)" "${MUI_TEMP1}"
goto donestart
StartMenu::Select /noicon /autoadd /text "$(MUI_INNERTEXT_STARTMENU_TOP)" /lastused "${MUI_STARTMENU_VARIABLE}" /checknoshortcuts "$(MUI_INNERTEXT_STARTMENU_CHECKBOX)" "${MUI_STARTMENU_DEFAULTFOLDER}"
>donestart:
Pop "${MUI_STARTMENU_VARIABLE}"

FunctionEnd
>

Done :D Download the latest version from CVS and use:

!define MUI_STARTMENU_REGISTRY_ROOT "HKCU"
!define MUI_STARTMENU_REGISTRY_KEY "Software\Test Software"
!define MUI_STARTMENU_REGISTRY_VALUENAME "Start Menu Folder"


The CVS version that was packaged today on 1/16 hasn't had its Modern UI/System.nsh updated since 1/13.

I also noticed there's a bug in the code I posted if the value isn't in the registry that I'm working on fixing right now.


Here's the fixed version, for some reason there's a problem with two calls to StartMenu::Select for whatever reason.




Function "${SETSTARTMENU}"

!insertmacro MUI_HEADER_TEXT $(MUI_TEXT_STARTMENU_TITLE) $(MUI_TEXT_STARTMENU_SUBTITLE)
ReadRegStr ${MUI_TEMP1} HKCU "Software\${MUI_PRODUCT}" "Start Menu Folder"
StrCmp "${MUI_TEMP1}" "" +3
StrCpy $R0${MUI_TEMP1}
goto donestart
StrCpy $R0${MUI_STARTMENU_DEFAULTFOLDER}
>donestart:
StartMenu::Select /noicon /autoadd /text "$(MUI_INNERTEXT_STARTMENU_TOP)" /lastused "${MUI_STARTMENU_VARIABLE}" /checknoshortcuts "$(MUI_INNERTEXT_STARTMENU_CHECKBOX)" "$R0"
Pop "${MUI_STARTMENU_VARIABLE}"

FunctionEnd
>

Hi!

hm, I'm newbie to SuperPiMPing. How exactly do I do that now? How can the installer retrieve the install dir and the Autostart folder from previous installation?

Or where do I find a hint for that?


Regards, Marc


First of all make sure you have the latest CVS version (see FAQ for details on getting it). Next, have a look in Examples\Modern UI\StartMenu.nsi. It's an example that does exactly what you are looking for.


thanks very much!


But somehow i dont see, how it gets the start menu position from Registry (also the install dir). An it also doesn't do it if i install it twice. The second time it doesn show the path of the first install. :-/

So how does it work?


The defines are missing in StartMenu.nsi. I'll fix that.


thanks, works now.