Setting correct icon for Shortcut in VS2010 Setup Project

32.8k views Asked by At

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.

4

There are 4 answers

3
Gert Arnold On BEST ANSWER

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.

0
AudioBubble On

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

0
Gian C. On

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

0
user16719 On

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!