Archive: Desktop icon duplicated four times


Desktop icon duplicated four times
Hi,

When installing my application, the desktop icon is duplicated 4 times, i.e. I see 4 icons of my application on the desktop, all of them pointing to the same EXE.

If I refresh the desktop with F5 then only one remains.

This is the script command I use to create the desktop icon:
CreateShortCut "$DESKTOP\MyApp.lnk" "$INSTDIR\myapp.exe"

That never happened with previous versions of my software, however on the last install script I added the "SetShellVarContext all" in order to have the installation shared with all users. Is that related?

What can I do?

Thanks


To refresh the desktop, use the code below:

!include WinMessages.nsh

Function .onInit
SendMessage "${HWND_BROADCAST}" "${WM_SETTINGCHANGE}" "" ""
FunctionEnd

Originally posted by deguix
To refresh the desktop, use the code below:
Thanks but this is a workaround to the problem.

I'd like that it just doesn't happen (if possible).

This is probably a scripting problem.

Remember: You can debug any part of the script using MessageBox command or using DumpState plugin. So even you can solve the problem here.

Or you can attach your script if you want it fast or sure.


I've seen this happen when a shortcut with the same name already exists under the "all users" area and then you add the same shortcut under the "current user". You can also get the problem to occur by creating the shortcuts through Windows so it appears to be a Windows issue. I've seen it happen other times but never really nailed down the cause. I guess you could check you script to make sure your not doing something like creating duplicate shortcuts.


I have only one call to:
CreateShortCut "$DESKTOP\MyApp.lnk" "$INSTDIR\myapp.exe"

If there is no solution I'll try the workaround proposed by deguix.


The following will assure only one instance.


!include "WinMessages.nsh"
...

IfFileExists "$DESKTOP\MyApp.lnk" lblAlreadyExists
CreateShortCut "$DESKTOP\MyApp.lnk" "$INSTDIR\myapp.exe"
Goto LblDone
lblAlreadyExists:
; the following will replace the existing shortcut, hope it was yours. This insures your target is right.
delete "$DESKTOP\MyApp.lnk"
CreateShortCut "$DESKTOP\MyApp.lnk" "$INSTDIR\myapp.exe"
; refresh incase incon changed since bloody windows caches them.
SendMessage "${HWND_BROADCAST}" "${WM_SETTINGCHANGE}" "" ""
lblDone:

...

Thanks a lot, I'll try this.
;)