nitesh.kodle123
nitesh.kodle123

Reputation: 1033

Not able to embed icon on shortcut?

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:

Upvotes: 0

Views: 1524

Answers (1)

Anders
Anders

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

Related Questions