ImmortalStrawberry
ImmortalStrawberry

Reputation: 6091

Setting correct icon for Shortcut in VS2010 Setup Project

I have a small app with a setup project. If I create a shortcut to my Primary Output, then this gets a standard Win7 icon and not the icon specified in my exe's Application Icon?

Whats the best way to make sure my desktop shortcut icon is the same icon as my exe? e.g. If I change the exe's icon then I'd like the Setup icon to change as well.

Upvotes: 16

Views: 33009

Answers (4)

Gian C.
Gian C.

Reputation: 179

Very simple way using IWshShortcut (works in .net 2 too):

WshRuntimeLibrary.IWshShortcut MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(fullPathLnk);    
string iconLoc = MyShortcut.IconLocation; // <- example: "c:\icon.ico,0"

I use to check if iconLoc still exists, fix if not, you can use to find and read icon file, etc etc

Upvotes: 1

user16719
user16719

Reputation: 51

You can add an icon from your target.exe file to the shortcut... in File System On Target Machine, browse to the shortcut in the folder you want to add the icon to (User's Desktop,etc). Right click the shortcut and select Properties Window. You'll see an Icon line... click it, select Browse, then browse to Application Folder/yourExe.exe (change from ICON to Exe files) and say OK. It will show you the icon from yourExe.exe that it has selected, say OK. You basically have to do the same thing for your Add/Remove Icon (appears in Control Panel/Uninstall)... properties page for your setup project. You have to do it for all shortcuts in different folders (User's Desktop, User's Startup, etc.) All icons good now!

Upvotes: 5

user2611793
user2611793

Reputation:

To add to Gert's answer: make sure you build your project first. Otherwise the setup app will not see the icon.

Upvotes: 2

Gert Arnold
Gert Arnold

Reputation: 109080

If you set the icon for the shortcut you can set a primary output as source. In the file system editor of the setup project, click on the "(Icon)" combobox in the properties pane of the shortcut, then option "(Browse...)", button "Browse...". You'll see this:

Add Output

Then add output and select the primary output of the exe.

Upvotes: 19

Related Questions