WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > At un-install remove renamed left over shortcuts best method?
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
onad
Senior Member

Registered: Dec 2004
From: Turkey

Question At un-install remove renamed left over shortcuts best method?

SUBJECT:
At un-install remove renamed left over shortcuts best method?

ISSUE:
If an NSIS installer installs an application, it is easy at un-install to remove a known by name shortcut. However is the shortcut is renamed by a users the .lnk name changed and the un-install of the shortcut will not be performed.

WISH:
Like to have for a un-install improvement:

Look for shortcut and recursively delete shortcuts from a known application name e.g. "MYAPP.EXE"
- All users Startmenu
- All users Desktop
- Current user Startmenu
- Current users Desktop

* NSIS function that performs and looks like the following:

$0 = set Target to look for e.g. "MYAPP.EXE"
$1 = $SM value via NSIS or $DESKTOP values via NSIS
$2 = Current user or all users

...

Function un.removeleftovershortcuts $0 $1 $2

;PSEUDOCODE:
;; Look for shortcut and recursively delete shortcuts
; compare lastpart .lnk target with \+$0 with first stripping part after $0
; if same then this is a shortcut to delete

; If found delete Shortcut via dialogbox ask Delete? Y/N
; If silent install always delete/ nverdelete via a set boolean
; Refresh desktop if needed

; REAL CODE HERE PLZ

FunctionEnd

...

I searched the Wiki but found no solution, maybe combine and adjust a lot of codesnippets from:
[url]http://nsis.sourceforge.net/Categoryisk%2C_Path_%26_File_Functions[/url]

But which are the best to start with?

QUESTION:
Anyone already once created such a script, be so kind as to share.

Somehow I have the feeling the "Locate" NSIS Script
http://nsis.sourceforge.net/Locate
could solve my problem but somehow cannot figure it out... maybe I should add sleep to the code ?

TIA

__________________
"Just do it"

Quick Link | Report this post to a moderator | IP: Logged

onad is offline Old Post 12-06-2006 04:04 PM
Click Here to See the Profile for onad Click here to Send onad a Private Message Find more posts by onad Add onad to your buddy list Edit/Delete Message Reply w/Quote
onad
Senior Member

Registered: Dec 2004
From: Turkey

To difficult? >:-)

__________________
"Just do it"

Quick Link | Report this post to a moderator | IP: Logged

onad is offline Old Post 12-07-2006 12:48 PM
Click Here to See the Profile for onad Click here to Send onad a Private Message Find more posts by onad Add onad to your buddy list Edit/Delete Message Reply w/Quote
Red Wine
Forum King

Registered: Mar 2006
From: Ath. GR

Hi onad,
Just some thought, have no idea if could be done.
A method with system plugin that retrieves the target property from shortcuts in combination with locate plugin. E.g. Get shortcuts from desktop one by one with locate, pass each one to system plugin to retrieve the target, compare the retrieved target with a defined string, and remove every shortcut that has target myApp.exe.
Another thought, some kind of modification on MoreInfo plugin to be able ro retrieve the target property, again in combination with locate plugin.

__________________
Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS

Quick Link | Report this post to a moderator | IP: Logged

Red Wine is offline Old Post 12-07-2006 06:58 PM
Click Here to See the Profile for Red Wine Click here to Send Red Wine a Private Message Find more posts by Red Wine Add Red Wine to your buddy list Edit/Delete Message Reply w/Quote
kichik
M.I.A.
[NSIS Dev, Mod]

Registered: Oct 2001
From: Jerusalem, Israel

The ShellLink plug-in allows you to retrieve the properties of shortcuts. You could scan through all shortcuts and compare their target to your target.

__________________
NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Quick Link | Report this post to a moderator | IP: Logged

kichik is offline Old Post 12-07-2006 07:09 PM
Click Here to See the Profile for kichik Click here to Send kichik a Private Message Visit kichik's homepage! Find more posts by kichik Add kichik to your buddy list Edit/Delete Message Reply w/Quote
Red Wine
Forum King

Registered: Mar 2006
From: Ath. GR

Thanks to kichik (always :-)) here is something:

code:
OutFile "locate_shellink.exe" ShowInstDetails show !include "FileFunc.nsh" !insertmacro Locate !define MyApp "$PROGRAMFILES\Mozilla Firefox\firefox.exe" Section SetShellVarContext all StrCpy $R0 '' ${Locate} "$DESKTOP" "/L=F /M=*.lnk /S=0B" "LocateCallback" IfErrors 0 +2 MessageBox MB_OK "Error" IDOK +2 MessageBox MB_OK "$$R0={$R0}" SectionEnd Function LocateCallback ShellLink::GetShortCutTarget "$R9" Pop $0 StrCmp '$0' '${MyApp}' 0 end StrCpy "$R0" "$R9" StrCpy "$0" StopLocate end: Push "$0" FunctionEnd

__________________
Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS

Quick Link | Report this post to a moderator | IP: Logged

Red Wine is offline Old Post 12-07-2006 07:51 PM
Click Here to See the Profile for Red Wine Click here to Send Red Wine a Private Message Find more posts by Red Wine Add Red Wine to your buddy list Edit/Delete Message Reply w/Quote
Red Wine
Forum King

Registered: Mar 2006
From: Ath. GR

Just tried another instance, uses RecFind.nsh and I think it is more accurate.
Besides it removes repeated wrong name shortcuts in a snap.

code:
# Execute compiled installer then manual create some copies of the generated # shortcut on desktop, then execute uninstaller and watch the action. OutFile "RecFind_shellink.exe" InstallDir '$EXEDIR' ShowInstDetails show ShowUninstDetails show !include 'RecFind.nsh' !define ICON_SEARCH '$DESKTOP\$R0\$R1' !define MyApp '$1\nsis.exe' !define Uninst 'unshortcut.exe' Section Install ; SetShellVarContext all ReadRegStr "$1" HKLM "Software\NSIS" "" createshortcut '$DESKTOP\nsis.lnk' '${MyApp}' ShellLink::SetShortCutWorkingDirectory '$DESKTOP\nsis.lnk' '$1' Pop $0 messagebox mb_ok 'errorlevel $0' writeuninstaller '$INSTDIR\${Uninst}' sectionend Section Uninstall ; SetShellVarContext all ReadRegStr "$1" HKLM "Software\NSIS" "" Delete '$DESKTOP\nsis.lnk' ${RecFindOpen} '$DESKTOP' '$R0' '$R1' ${RecFindFirst} ; DetailPrint '${ICON_SEARCH}' ShellLink::GetShortCutTarget '${ICON_SEARCH}' Pop $0 StrCmp '$0' '${MyApp}' 0 end messagebox mb_ok '${ICON_SEARCH}' Delete '${ICON_SEARCH}' end: ${RecFindNext} ${RecFindClose} Delete '$INSTDIR\${Uninst}' SectionEnd

__________________
Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS

Quick Link | Report this post to a moderator | IP: Logged

Red Wine is offline Old Post 12-08-2006 12:38 AM
Click Here to See the Profile for Red Wine Click here to Send Red Wine a Private Message Find more posts by Red Wine Add Red Wine to your buddy list Edit/Delete Message Reply w/Quote
onad
Senior Member

Registered: Dec 2004
From: Turkey

Great! Thanks Red Wine and Kichik,

I will try the solutions and see if they fit in my full goal.

Note that I still did not took an extra nap since I was a really busy creating a plugin to solve the problem. I think I still will finish that plugin and post it to a Wikipage anyhow.

I also discovered that I did something wrong resolving the shortcuttarget and storing the value (, so that is why shelllink and locate combination did not work at all during my tryouts...

__________________
"Just do it"

Quick Link | Report this post to a moderator | IP: Logged

onad is offline Old Post 12-08-2006 09:15 AM
Click Here to See the Profile for onad Click here to Send onad a Private Message Find more posts by onad Add onad to your buddy list Edit/Delete Message Reply w/Quote
onad
Senior Member

Registered: Dec 2004
From: Turkey

Thumbs up

Tried it, and the second solution really works good and fast almost without enlarging the intaller size, thanks!

No need for yet another plugin

__________________
"Just do it"

Quick Link | Report this post to a moderator | IP: Logged

onad is offline Old Post 12-08-2006 02:23 PM
Click Here to See the Profile for onad Click here to Send onad a Private Message Find more posts by onad Add onad to your buddy list Edit/Delete Message Reply w/Quote
Red Wine
Forum King

Registered: Mar 2006
From: Ath. GR

Well, I got a step deeper.
Following example removes normal/renamed shortcut(s) from desktop and also removes normal/renamed shortcus from Start Menu along with the created Start Menu folder even if the folder is renamed and/or moved-copied elsewhere inside Start Menu!

Attachment: test.nsi
This has been downloaded 228 time(s).

__________________
Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS

Quick Link | Report this post to a moderator | IP: Logged

Red Wine is offline Old Post 12-09-2006 11:06 AM
Click Here to See the Profile for Red Wine Click here to Send Red Wine a Private Message Find more posts by Red Wine Add Red Wine to your buddy list Edit/Delete Message Reply w/Quote
Red Wine
Forum King

Registered: Mar 2006
From: Ath. GR

A little bit enhanced in order to manage shortcuts that have been copied/renamed from current user to all users and vice versa :-)

Attachment: test.nsi
This has been downloaded 361 time(s).

__________________
Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS

Quick Link | Report this post to a moderator | IP: Logged

Red Wine is offline Old Post 12-11-2006 11:49 AM
Click Here to See the Profile for Red Wine Click here to Send Red Wine a Private Message Find more posts by Red Wine Add Red Wine to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 09:22 AM. Post New Thread    Post A Reply
  Last Thread   Next Thread
WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > At un-install remove renamed left over shortcuts best method?
Show Printable Version
 | 
Email this Page
 | 
Subscribe to this Thread

Forum Jump:
 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is off
vB code is ON
Smilies are ON
[IMG] code is ON