16

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.

Matt
  • 25,467
  • 18
  • 120
  • 187
BlueChippy
  • 5,935
  • 16
  • 81
  • 131
  • I can add the ico file to my Application Folder, and then reference this with my shortcut, but that means remembering to keep the Application and the Setup project in step all the time. – BlueChippy Jan 26 '12 at 07:32
  • Select the shortcut you created in the Setup project and set its Icon property. The default is (None) so you get the plain jane. – Hans Passant Jan 26 '12 at 10:21
  • But that means including the icon in the application folder...something that is NOT needed with a ClickOnce deployment where it is picked up from the exe. – BlueChippy Jan 29 '12 at 06:26

4 Answers4

19

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.

Gert Arnold
  • 105,341
  • 31
  • 202
  • 291
  • Thanks, but try it...it doesn't create a shortcut with the Exe's icon, it used the standard windows/vs icon instead. If I install with ClickOnce it uses the Exe's icon. The only way appears to be to add the icon to the SetupProject and reference that...of course, this means that if you update the exe then you need to update the setup...which I am hoping to avoid. – BlueChippy Jan 29 '12 at 06:27
  • 1
    Hmmm, I do this all the time. Then it shows the exe's icon in the window above with some number below it as name. Do you see that happen? – Gert Arnold Jan 29 '12 at 08:54
  • 6
    Found it! The file types was still set to *.ico - changed to *.exe and the icon appears! yay! – BlueChippy Jan 29 '12 at 11:21
5

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!

user16719
  • 51
  • 1
  • 1
2

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

1

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

Gian C.
  • 169
  • 1
  • 8