Reputation: 2383
When users install my software, it creates shortcut on the user's desktop. The name of the shortcut also reflects the version being installed.
It turns out that some of my clients do install multiple versions (although that is no problem, no conflicts or whatever) but it means that user's desktop is bloated with lots of shortcuts for the several various different versions that they have installed over time. (e.g. SchoolServer 7.1.lnk
, SchoolServer 7.2.lnk
, SchoolServer 8.5.lnk
and then the current SchoolServer 9.0.lnk
)
They have to be deleting these obsolete shortcuts manually.
How can I achieve this in my NSIS script?
Note: I have tried deleting the shortcuts on the desktop with wildcat for all versions and then create the shortcut for the installed version, but it created the new shortcut and still left the old shortcuts there. Code I used is below:
;first delete stale shortcuts matching the wildcat
Delete "$DESKTOP\SchoolServer *.lnk"
;create the new shortcut
CreateDirectory "$INSTDIR"
CreateShortCut "${ICON_URL}" "$INSTDIR\SchoolServer.exe" "" "" "" SW_SHOWMAXIMIZED ALT|CONTROL|SHIFT|F5 "SchoolServer"
Upvotes: 1
Views: 2129
Reputation: 12882
Use SetShellVarContext prior to deleting, to switch to the current user:
SetShellVarContext current
Delete "$DESKTOP\SchoolServer *.lnk"
SetShellVarContext all
Upvotes: 3