Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 466
BlueChippy Avatar asked Jan 26 '12 05:01

BlueChippy


People also ask

How do I change the icon of a setup file?

Select the current icon and click Modify selected icon.... Another file browser window will expand. Select your ICO file and click Open. In the File Explorer window, go to the location of your icon file, then click the icon file to select it. You'll now see the replacement icon.

How do I assign an icon to a Shortcut?

Right-click the icon and click Properties. Click the Shortcut tab (if one is available), and then click Change Icon. Click the icon that you want to use from the list, click OK, and then click OK.

How do I add an icon to setup project in Visual Studio?

In the properties window, select the application tab. In the application tab, there is a radio button saying Icon and manifest. Select that and browse and select your custom icon for the application in the Icon drop down menu. Save this answer.

How do I change the icon of a Shortcut in Linux?

You have to go to /usr/share/applications with elevated privileges (command: sudo nemo ) and then modify the icon from there (Right click on icon you want to change -> properties -> click on the icon in upper left of dialog). Save this answer.


4 Answers

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.

like image 149
Gert Arnold Avatar answered Oct 17 '22 09:10

Gert Arnold


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!

like image 42
user16719 Avatar answered Oct 17 '22 10:10

user16719


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

like image 37
Mike Bethany Avatar answered Oct 17 '22 10:10

Mike Bethany


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

like image 23
Gian C. Avatar answered Oct 17 '22 11:10

Gian C.