Archive: Removing Renamed Desktop Shortcuts


Removing Renamed Desktop Shortcuts
Hi,

OK, I need to write an installer that detects/removes a previous version of an application and its desktop shortcut and then installs the updated version and recreates the shortcut. The previous version was not installed by NSIS.

The problem that I'm having right now is that users often rename the desktop shortcut for the app, making script-based removal procedures more complicated.

Anyone have any suggestions for how to tackle this? I need to be able to detect/remove any and all desktop shortcuts for this app regardless of what the user has renamed it to....


Thanks :igor:


Script to delete shortcuts by target file name from $DESKTOP, $QUICKLAUNCH, $SMPROGRAMS. You can easily change it to delete by working directory and so on. Script used Locate plugin and ShellLink plugin

Name "Output"
OutFile "Output.exe"

!include "FileFunc.nsh"
!insertmacro GetFileName

Section
StrCpy $0 "SmashChat.exe" #File name of the application

locate::Open /NOUNLOAD "$DESKTOP" "/F=1 /D=0 /M=*.lnk /P=$QUICKLAUNCH|$SMPROGRAMS /B=1" .r1
StrCmp $1 -1 0 locatenext
MessageBox MB_OK "Error" IDOK endfind

locatenext:
locate::Find /NOUNLOAD .r1 .r2 .r3 .r4 .r5 .r6

StrCmp $1 '' endfind
ShellLink::GetShortCutTarget $1
Pop $7
${GetFileName} "$7" $7

StrCmp $7 $0 0 locatenext
Delete $1
goto locatenext

endfind:
locate::Close
SectionEnd

Thanks, I'll play around w/ that :)