Archive: Vista: Desktop icon is not removed


Vista: Desktop icon is not removed
Hello world,

I am doing the first Vista tests with an NSIS installer that works perfectly on 2000 and XP. I noticed that on Vista, the uninstaller does remove the start menu shortcuts, but not the desktop icon. (I only use 'all users' shortcuts.)

Searching the NSIS pages, I found two essential hints:
* Use "RequestExecutionLevel admin"
* Use "SetShellVarContext all" at both install and uninstall

I did both, but still the desktop icon is not removed on Vista. Shortened code sample:

...
RequestExecutionLevel admin
...
Section
...
SetShellVarContext all
SetOutPath "$SMPROGRAMS\MyApp"
CreateShortcut "MyApp.lnk" "$INSTDIR\MyApp.exe"
SetOutPath $DESKTOP
CreateShortcut "MyApp.lnk" "$INSTDIR\MyApp.exe"
SectionEnd
...
Section Uninstall
...
SetShellVarContext all
RmDir /r /REBOOTOK "$SMPROGRAMS\MyApp"
Delete "$DESKTOP\MyApp.lnk" # <-- Does not work on Vista
SectionEnd
What the heck am I doing wrong?

Even if you delete the shortcut, the icon isn't immediately removed from a Vista desktop. It remains until you refresh the desktop (or restart the computer).


Hmmm... strange, it does work well under 2000/XP.

Is there a way to trigger such a refresh from within the NSIS uninstaller to make the icon actually disappear?


http://nsis.sourceforge.net/Refresh_Desktop shows two ways to do that, though I haven't personally confirmed yet that it will clear the shortcut off the desktop.


I have just tried - triggering a refresh does actually make the icon disappear.

Thanks for the hint!