Archive: Help with Startmenu macros?


Help with Startmenu macros?
Hi All,

I've been trying for several days now to understand how to use NSIS to make my installer for a Java program (including the JRE and Java3D). Since the API is changing rapidly, I now have part of one made for the latest beta (NSIS 2b4), with CVS code from last night. Problem:

I have a section for creating startmenu icons, like so:

!insertmacro MUI_STARTMENU_WRITE_BEGIN
CreateDirectory "$SMPROGRAMS\${COMPANY_NAME}"
CreateDirectory "$SMPROGRAMS\${COMPANY_NAME}\${MUI_PRODUCT}"
CreateShortCut "$SMPROGRAMS\${COMPANY_NAME}\${MUI_PRODUCT}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\${COMPANY_NAME}\${MUI_PRODUCT}\${MUI_PRODUCT}.lnk" "$INSTDIR\${EXE_NAME}" "" "$INSTDIR\${EXE_NAME}" 0
!insertmacro MUI_STARTMENU_WRITE_END

It gives me nasty errors:

!insertmacro: MUI_STARTMENU_WRITE_BEGIN
warning: unknown variable "{MUI_STARTMENUPAGE_VARIABLE}" detected, ignoring (macro:MUI_STARTMENU_WRITE_BEGIN:5)
warning: unknown variable "{MUI_STARTMENUPAGE_VARIABLE}" detected, ignoring (macro:MUI_STARTMENU_GETFOLDER_IFEMPTY:2)
warning: unknown variable "{MUI_STARTMENUPAGE_DEFAULTFOLDER}" detected, ignoring (macro:MUI_STARTMENU_GETFOLDER:13)
Usage: StrCpy $(user_var: output) str [maxlen] [startoffset]
Error in macro MUI_STARTMENU_GETFOLDER on macroline 13
Error in macro MUI_STARTMENU_GETFOLDER_IFEMPTY on macroline 4
Error in macro MUI_STARTMENU_WRITE_BEGIN on macroline 8


Does anyone know why? It used to work :( I'm baffled most of the time, trying to create a fairly simple installer.....

Thanks!


Never mind
Apparently the InsertMacro lines must be deleted for beta4 to compile it.... but eh MUI readme that comes with beta 4 seems to suggest otherwise. I'm totally lost here. Am I doing something wrong, or reading the wrong docs?

NSIS is impressive, if a bit confusing....


The begin and end macros are still needed. If MUI_STARTMENUPAGE_VARIABLE is not defined it's probably because you didn't insert the start menu page macro (MUI_PAGE_STARTMENU). There is an example called StartMenu.nsi in Examples\Modern UI.

But why would you want to show a start menu page if you don't use its input? In your code above you're using a static folder name instead of the one chosen by the user in the start menu page.


Ok, I'm starting to understand....
Hmmmm... ok, well how do I give the user an option to install startmenu icons, but don't give them a choice as to where they go or what they're named? I assume a StartmenuPage would give them the opportunity to decide where things go in the startmenu, right? Which is why I wouldn't want to have a page like that. Instead I just put an installer section in that would write the shortcuts. In that case, do I still need the macros?

There's a good chance that I'm misunderstanding how NSIS is meant to work, so please correct me if that's the case! (I really do think this is great software, I'm just confused)

Thanks :)



MessageBox MB_YESNO|MB_ICONQUESTION "Do you wish to create start-menu shortcuts for ${MUI_PRODUCT}?" IDNO NoShortcuts
CreateDirectory "$SMPROGRAMS\${COMPANY_NAME}"
CreateDirectory "$SMPROGRAMS\${COMPANY_NAME}\${MUI_PRODUCT}"
CreateShortCut "$SMPROGRAMS\${COMPANY_NAME}\${MUI_PRODUCT}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\${COMPANY_NAME}\${MUI_PRODUCT}\${MUI_PRODUCT}.lnk" "$INSTDIR\${EXE_NAME}" "" "$INSTDIR\${EXE_NAME}" 0
NoShortcuts:


-Stu

You don't need to insert the MUI_STARTMENU_WRITE_BEGIN/END macros. It's only needed if you want to allow the user to choose the start menu folder. If you wish to just give the user a choice weather to create it or not make a section out of it or use a MessageBox or anyother method of input like Afrow suggseted.