Archive: CreateShortCuts for all users


CreateShortCuts for all users
I create some shortcuts like this :

SetShellVarContext current
ReadINIStr $3 "$PLUGINSDIR\user.ini" "Field 3" "State"
StrCmp $3 "1" 0 +2
SetShellVarContext all
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\CitePlus1.lnk" "$INSTDIR\CitePlus1.exe" "" "$INSTDIR\deboeck.ICO"
CreateShortcut "$DESKTOP\CitePlus1.lnk" "$INSTDIR\CitePlus1.exe" "" "$INSTDIR\deboeck.ICO"
CreateShortcut "$QUICKLAUNCH\CitePlus1.lnk" "$INSTDIR\CitePlus1.exe" "" "$INSTDIR\deboeck.ICO"

In uninstaller I delete them like this :

SetShellVarContext current
ReadINIStr $3 "$PLUGINSDIR\user.ini" "Field 3" "State"
StrCmp $3 "1" 0 +2
SetShellVarContext all
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk"
Delete /REBOOTOK $INSTDIR\uninstall.exe
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\CitePlus1.lnk"
Delete /REBOOTOK "$DESKTOP\CitePlus1.lnk"
Delete /REBOOTOK "$QUICKLAUNCH\CitePlus1.lnk"

When SetShellVarContext is set to current, the shortcuts are deleted, but when SetShellVarContext is set to all, only the shortcut in the quicklaunch bar is deleted (apparently because NSIS doesn't create the quicklaunch shortcut in All Users but in Current User).

Any ideas?

Lieven


My guess is that your "$PLUGINSDIR\user.ini" will only exist for the installer.

Rather than check the value in the INI file, check if the shortcuts exist for either user and then delete.

E.g.

!macro Delete File
SetShellVarContext current
IfFileExists "${File}" +2
SetShellVarContext all
Delete "${File}"
!macroend

!insertmacro Delete "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk"

; ...etc



-Stu

SetShellVarContext current
ReadINIStr $3 "$PLUGINSDIR\user.ini" "Field 3" "State"
StrCmp $3 "1" 0 +2
SetShellVarContext all

Apparently, the uninstaller doesn't now the state anymore of Field 3... If you install, is it possible to save variables so you can access them when you uninstall?

Lieven


Wonderfull! thx!

Is there a way to save a variable so you can access it in the uninstaller?

Lieven


You'd have to save its value in the registry or in an INI file.

-Stu