Archive: Problems creating shortcuts on Vista (32 bit) in "current" user context


Problems creating shortcuts on Vista (32 bit) in "current" user context
Using NSIS 2.22 on to create an installer that I then run on Windows Vista I create two shortcuts during installation, one in the "all" context and another in the "current" context as follows:

SetShellVarContext all
CreateDirectory "$SMPROGRAMS\FolderName"
CreateShortCut "$SMPROGRAMS\FolderName\ShortcutName.lnk" "$INSTDIR\AppName.exe" "L=$(LanguageTLA)" "$INSTDIR\Console.exe" 0
SetShellVarContext current
CreateDirectory "$SMPROGRAMS\FolderName"
CreateShortCut "$SMPROGRAMS\FolderName\ShortcutName2.lnk" "$INSTDIR\AppName2.exe" "L=$(LanguageTLA)" "$INSTDIR\AppName2.exe" 0

(Actually, for the "current" context shortcut I do use a language string for the shortcut name - but I have tried with a normal string as in the above extract and the symptoms are unchanged).

Though the "FolderName" folder _is_ correctly created in both the "all" context (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\FolderName) and the "current" context (C:\Users\testpc1\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\FolderName) _both_ shortcuts are created in the "all" folder.

I have used MessageBox to show that $SMPROGRAMS is being correctly expanded dependent on the preceeding SetShellVarContext in both sections.

Further, when I uninstall I do the following:

SetShellVarContext all
Delete "$SMPROGRAMS\FolderName\ShortcutName.lnk"
RMDir "$SMPROGRAMS\FolderName"

SetShellVarContext current
Delete "$SMPROGRAMS\FolderName\ShortcutName2.lnk"
RMDir "$SMPROGRAMS\FolderName"

and I find that ShortcutName.lnk is deleted but that ShortcutName2.lnk is not deleted.

Has anyone else seen this and if so did they find out why and how to avoid this behaviour as I can't figure it out I'd appreciate any advice.

Thanks

Tim


Sounds like some kind of legacy redirection

Try using "RequestExecutionLevel admin" (or highest)

And if you are a standard user and elevate with UAC, you will be running as the admin and not "yourself" so you should not use "SetShellVarContext current" at all because it probably will not resolve to the correct folders for you