Archive: SMPROGRAMS is acting kinda weird


SMPROGRAMS is acting kinda weird
Hey guys,

I'm trying to build an installer which (depending on the user's rights) either creates startmenu-shortcuts for all or only for the current user.
That wouldn't be really kinda problem, but my installer only adds functionality to an already installed programm.
Unfortunately, this programm doesn't store it's startmenu-path into the registry), so I came up with this:


(...)
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "$SMPROGRAMS\My App"
(...)
Var mySMDir
(...)
!insertmacro MUI_PAGE_STARTMENU mySMPage $mySMDir
(...)
Section "Startmenu"
!insertmacro MUI_STARTMENU_WRITE_BEGIN mySMPage
SetShellVarContext all
ClearErrors

IfFileExists "$SMPROGRAMS\Company\Product" +1 +3
StrCpy $mySMDir "$SMPROGRAMS\Company\Product"
Goto mySMDone
IfFileExists "$SMPROGRAMS\Company" +1 +3
StrCpy $mySMDir "$SMPROGRAMS\Company"
Goto mySMDone
IfFileExists "$SMPROGRAMS\Product" +1 +2
StrCpy $mySMDir "$SMPROGRAMS\Product"

mySMDone:
WriteINIStr "$INSTDIR\..\${THREADLINK}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\$mySMDir\${THREADLINK}.lnk" "$INSTDIR\..\${THREADLINK}.url" "" "%SystemRoot%\system32\shell32.dll" "13"
CreateShortCut "$SMPROGRAMS\$mySMDir\${UNINSTALLER}.lnk" "$INSTDIR\..\${PRODUCT_PUB_SHORT}_${PRODUCT_NAME}_Uninstall.exe"

IfErrors 0 myNoSMError
SetShellVarContext current
WriteINIStr "$INSTDIR\..\${THREADLINK}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\$mySMDir\${THREADLINK}.lnk" "$INSTDIR\..\${THREADLINK}.url" "" "%SystemRoot%\system32\shell32.dll" "13"
CreateShortCut "$SMPROGRAMS\$mySMDir\${UNINSTALLER}.lnk" "$INSTDIR\..\${PRODUCT_PUB_SHORT}_${PRODUCT_NAME}_Uninstall.exe"

myNoSMError:
SetOutPath "$INSTDIR"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd


But this doesn't work, because the startmenu-page always shows "C:\Users\<My Username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\My App" - and it's getting even stranger if you select one of the entries below that input-field (e.g. when selecting the folder "ATI Tray Tools"), because the input-field then changes to "ATI Tray Tools\C:\Users\<My Username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\My App"

Setting "MUI_STARTMENUPAGE_DEFAULTFOLDER" to "$SMPROGRAMS\$mySMDir" also doesn't work.. :(

[-EDIT-]
Also, whenever I use the default ("My App"), I get 3 errors within the log - but the app _always_ requests (and gets) admin-rights?!
[-/EDIT-]

Any help would be greatly appreciated!

Best regards,
Martin :)

Okay, fixed the problem myself.. :)

First problem was:

IfFileExists "$SMPROGRAMS\Company\Product" +1 +3
StrCpy $mySMDir "$SMPROGRAMS\Company\Product"
Goto mySMDone
IfFileExists "$SMPROGRAMS\Company" +1 +3
StrCpy $mySMDir "$SMPROGRAMS\Company"
Goto mySMDone
IfFileExists "$SMPROGRAMS\Product" +1 +2
StrCpy $mySMDir "$SMPROGRAMS\Product"

Each StrCpy-line includes "$SMPROGRAMS", so that's surely the reason for the strange behavior on the startmenu-page.

Additionally, I removed the stuff for the startmenu-page and instead modified the code to create the shortcuts when the section gets processed - this means less possibilities for the user to change the startmenu-folder..
But that's ok, the user installs an add-on, not a standalone program.. ;)

/Martin.. :)