Old 13th June 2003, 18:31   #1
banaman8d
Junior Member
 
Join Date: May 2003
Posts: 19
Follow up...

After taking a look in the Contrib/Modern UI/system.nsh, I think I have located the problem. The modern UI functions that read the registry key don't get called when the installer is run silenty, but if you are creating shortcuts like this:

; This won't get called in a silent install
; so MUI_STARTMENUPAGE_VARIABLE isn't set.
; This is because it expands to a Page command
; and these are skipped in a silent install.
!insertmacro MUI_PAGECOMMAND_STARTMENU

.
.
.

; The Sections will always run
Section
...
MUI_STARTMENU_WRITE_BEGIN

; This won't do what we expect in a silent install because
; ${MUI_STARTMENUPAGE_VARIABLE wasn't set.
CreateShortCut "$SMPROGRAMS\${MUI_STARTMENUPAGE_VARIABLE}\${MUI_PRODUCT}.lnk" "$INSTDIR\${MUI_PRODUCT}.exe"

MUI_STARTMENU_WRITE_END
...
SectionEnd


The code inside is executed and the code that MUI_STARTMENU_WRITE_END expands to writes the registry key. This means that you will write the shortcuts, AND the registry key will be clobbered if there was one already in the registry.

To make the STARTMENUPAGE stuff work with silent installers as well as for a repair install (one where you already installed but want to install over it), the code to get the default folder should:

1.) Assign the string in the regkey to MUI_STARTMENU_VARIABLE if it exists.
2.) If it doesn't exist, assign the MUI_STARTMENUPAGE_DEFAULTFOLDER to the MUI_STARTMENU_VARIABLE, (which will get written when the MUI_STARTMENU_WRITE_END is reached). And this code should be called before the Page commands are - not in the page command because they won't get called in a silent installer. This requirement makes .onInit a good choice.



To fix the problem, put this line into the .onInit function.

!insertmacro MUI_STARTMENUPAGE_INIT


and the corresponding macro is:

!macro MUI_STARTMENUPAGE_INIT
;Initialize MUI_STARTMENUPAGE_VARIABLE so it is set when we
;are run silently, or as a repair (install over a previous).
Push $R0
ReadRegStr $R0 "${MUI_STARTMENUPAGE_REGISTRY_ROOT}" \
"${MUI_STARTMENUPAGE_REGISTRY_KEY}" \
"${MUI_STARTMENUPAGE_REGISTRY_VALUENAME}"
IfErrors +3
StrCpy ${MUI_STARTMENUPAGE_VARIABLE} $R0
Goto +2

; Get default if no regkey
StrCpy ${MUI_STARTMENUPAGE_VARIABLE} \
"${MUI_STARTMENUPAGE_DEFAULTFOLDER}"
Pop $R0
!macroend

Last edited by banaman8d; 13th June 2003 at 18:48.
banaman8d is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump