How to change the icon of .bat file programmatically?

SaM picture SaM · Aug 19, 2008 · Viewed 177.5k times · Source

I'd like to know what's the way to actually set the icon of a .bat file to an arbitrary icon. How would I go about doing that programmatically, independently of the language I may be using.

Answer

Sören Kuklau picture Sören Kuklau · Aug 19, 2008

Assuming you're referring to MS-DOS batch files: as it is simply a text file with a special extension, a .bat file doesn't store an icon of its own.

You can, however, create a shortcut in the .lnk format that stores an icon.