Add icon to existing EXE file from the command line

Tomas Andrle picture Tomas Andrle · Mar 23, 2009 · Viewed 48k times · Source

Is there a command line tool that can add an icon to an existing executable file? It should be able to set the icon as the file's "main" icon that is shown in Explorer.

I don't have Visual Studio and cannot recompile the exe with custom resources containing the icon.

UPDATE: The best tool I have found since posting this question is by far the RCEDIT.exe utility that is included with WinRun4J.

Answer

natevw picture natevw · Nov 21, 2014

Sorry, I haven't personally tried this one just yet, but because I am wanting this while bundling up an atom-shell app, I found it very interesting when https://github.com/atom/rcedit showed up in my first search for the RCEDIT utility mentioned in other answers.

One of its commands is:

$ rcedit "path-to-exe-or-dll" --set-icon "path-to-ico"

…so assuming this works, it is likely the solution I will use — my Windows build machine is already set up to fetch source using git and compile via gyp.

UPDATE: there's a pre-built executable available via https://github.com/atom/rcedit/releases/ and it works well for me on Win7 (from Git Bash/Msys shell although I'd be surprised if that makes a difference).