Reputation: 1033
I created an window application for which I need to create setup.For creating setup i am using NSIS. I had written script to create setup file which creates shortcut on Desktop and Star Menu now i need to embed an icon to the shortcut.Code is as follows:
Function "CREATE"
createShortCut "$SMPROGRAMS\lnkname.lnk" "$DESKTOP\Application.exe" "ADC" "$DESKTOP\icon.ico" 0
createShortCut "$DESKTOP\lnkname.lnk" "$DESKTOP\ApplicationMDMO\ApplicationMDMO\bin\debug\Application.exe" "ADC" "$DESKTOP\icon.ico" 0
FunctionEnd
Now I created an uninstaller to this installer.In this uninstaller I am deleting the shortcut file and the application file which are installed by installer.
Function "Uninstall"
Delete "$INSTDIR\*.*"
Delete "$DESKTOP\lnkname.lnk"
Delete "$SMPROGRAMS\lnkname.lnk"
FunctionEnd
Problem:
When I am trying to delete the shortcuts which are at desktop and all programs the all program short cut doesn't get deleted unless I add this code.
RequestExecutionLevel admin //at the beginning
SetShellVarContext all // at the section
But when I add these to lines the icon disappears
When I am excluding the code written in the above code the shortcut at "all Programs " is not purged.
Upvotes: 0
Views: 1524
Reputation: 101756
When using SetShellVarContext all
the path $DESKTOP
resolves to might change if you had to elevate with UAC etc.
I assume you are not really installing the application .exe and other files on the users desktop? If you place the .exe and the .ico somewhere under $ProgramFiles
it should work...
InstallDir "$ProgramFiles\MyApp"
Section
SetShellVarContext all
SetOutPath "$InstDir"
File myapp.exe
File myapp.ico
CreateShortcut "$DESKTOP\myapp.lnk" "$InstDir\myapp.exe" "" "$InstDir\myapp.ico" 0
SectionEnd
Upvotes: 1