Archive: CreateShortCut with an icon


CreateShortCut with an icon
Hi,

I guess I don't understand how to set an icon for my shortcut. I've searched the forum and some examples but haven't seen anything that seems relevent.

My code looks like:
CreateShortCut "My App.lnk" "My App.exe" "" "myapp.jpg"

and what I'm trying to accomplish is having myapp.jpg be the icon used for my shortcut. The shortcut gets created just fine, but the icon is not there. I've also tried including the jpeg file in my list of Files for the installer, but that didn't make any difference.

What am I doing wrong? I haven't come across any examples that try to use a jpeg file for the icon. The few examples I've seen all specify an exe file here.

Thanks for any help,
Beth


You need to use a valid icon resource. Correct me if I'm wrong but you can either use, *.ico, *.dll, or *.exe files.

Rob


Thanks for the reply.

I guess I am still confused as to what makes a "valid icon resource". I found a .ico file on my file system and gave that as input to the CreateShortCut tag. However that still didn't work.

If I look at the properties of my newly created shortcut and try to "Change Icon", windows (W2K) reports an error that it can't find the file that I gave initially.

Are there any links out there that describe how this works?

Thanks again,
Beth


Try setting it to an exe that is on your system and see if it works. I wasnt sure about the ico resource.


ok, I changed my shortcut to use notepad.exe as I saw in one of the example .nsi files and that worked (i.e. I saw the little notepad icon when I created the shortcut).

So what does this mean if I am trying create a shortcut to a java app? Is the only way to set the image of the shortcut through an exe? What is the best way to accomplish this if I have either a jpeg file or an .ico file?

Thanks,
Beth


I think your code is wrong. For the icon it should be like:

Icon "c:\my documents\savirc\icons\savDesk.ico"


And for the shortcuts:
CreateShortCut "$DESKTOP\savIRC.lnk" "$INSTDIR\savirc.exe"


There are a few different ways you can make your icon's. In microangelo, or a regular graphic manipulation program such as Photoshop or Fireworks. But if you use the regular graphic apps, you will have to get a converter program, to convert your graphic to .ico. Don't forget that without tweaking the NSIS code, you can only use 16 colors for your icon. Dimensions: 32x32x16

Hopefully this answers your question.

Btw you can download microangelo at download.com

Originally posted by bbh
ok, I changed my shortcut to use notepad.exe as I saw in one of the example .nsi files and that worked (i.e. I saw the little notepad icon when I created the shortcut).

So what does this mean if I am trying create a shortcut to a java app? Is the only way to set the image of the shortcut through an exe? What is the best way to accomplish this if I have either a jpeg file or an .ico file?

Thanks,
Beth
You should be able to compile a dll with the icon file in the resources section. This could be done easily with any c or c++ compiler.

ok, I found the problem. I had copied the icon file to my working directory and thus was just giving the name of the icon file. This didn't work. But I changed to give the complete path and it is now working.

Then I tried giving a relative path from my working directory, i.e. "src\images\myicon.ico" and that didn't work either.

Is there any way for this to work without giving the complete path? So this script can move from machine to machine without having to worry about complete paths?

Thanks for all your help.
Beth


If you are installing to $INSTDIR, just use that variable in the string.
CreateShortCut "My App.lnk" "My App.exe" "" "$INSTDIR\my.ico"