Skip to content
⌘ NSIS Forum Archive

SetShellVarContext at runtime

3 posts

LIGHTNING UK!#

SetShellVarContext at runtime

I'm looking to give users of my program the choice of creating shortcuts under 'All Users' or just their user.

Some installers I've seen have a dedicated page for this where it offers choices of 'Everyone' & 'Just Me' - I'm sure you know what I'm getting at!

Anyway, I'm not so hot on making custom pages so I was going to settle with a simple MessageBox asking them how they'd like to proceed.

Section "Main Program Files" SecCore
SectionIn 1 RO

SetOutPath "$INSTDIR"
File "DVDDecrypter.exe"
File "ReadMe.txt"

SetOutPath "$INSTDIR\Sounds"
File "Sounds\Success.wav"
File "Sounds\Error.wav"

MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to create shortcuts for all users instead of just yourself?" IDYES ShortcutsAllUsers IDNO ShortcutsJustMe
ShortcutsAllUsers:
SetShellVarContext all
ShortcutsJustMe:
SetShellVarContext current
ShortcutsConfigured:

CreateDirectory "$SMPROGRAMS\DVD Decrypter"
CreateShortCut "$SMPROGRAMS\DVD Decrypter\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\DVD Decrypter\DVD Decrypter.lnk" "$INSTDIR\DVDDecrypter.exe" "" "$INSTDIR\DVDDecrypter.exe" 0
CreateShortCut "$SMPROGRAMS\DVD Decrypter\DVD Decrypter Read Me.lnk" "$INSTDIR\ReadMe.txt" "" "$INSTDIR\ReadMe.txt" 0
SectionEnd
That's what I'd had in mind but it doesnt work. Has anyone already done what I'm trying to achieve?

Thanks in advance.
pengyou#
If "all users" is selected, you need to jump over the "current user" option:
ShortcutsAllUsers:
SetShellVarContext all
Goto MakeShortcuts
ShortcutsJustMe:
SetShellVarContext current
MakeShortcuts:
(insert your CreateShortcut commands here)
LIGHTNING UK!#
Wouldn't you know it would be something simple like that!

Next problem is that the $QUICKLAUNCH variable doesnt seem to goto the 'All Users' folder - but then I'm not sure if that folder exists / works like that anyway.

Many Thanks 🙂