30

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.

Tomas Andrle
  • 13,132
  • 15
  • 75
  • 92

4 Answers4

17

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).

natevw
  • 16,807
  • 8
  • 66
  • 90
  • The command converts my 11 MB, workable exe into a 224 KB, corrupted one. Extracting it I only see .rsrc data. Where am I doing it wrong? – Ooker Dec 22 '22 at 07:15
16

Resource Hacker is a free tool that allows you to modify resources in executables, and it can be scripted from the command line.

Simon Lieschke
  • 13,058
  • 6
  • 46
  • 60
3

In my case, trying to add an icon using RCEdit.exe with either /A or /I switches resulted in a trimmed executable. I have a NSIS (NullSoft Installer System) - created setup that was originally 13 MiB, but after running RCEdit to add an icon to it, all of what remains of it is only a few kilobytes (close to the size of the icon), but yes the executable shows the icon.

Adding the icon using Resource Hacker worked for me. It doesn't even need an option to set the icon as default, being the only icon group resource. I used 103 as the name of the resource and 1033 as the language.

bitoolean
  • 51
  • 2
  • Interestingly resource hacker doesn't let you add an exe icon if the exe is using the default -- but if you name it 103 it works. – Tim Barrass May 14 '20 at 07:26
2

Have you tried ResourceTuner Console?

BobbyShaftoe
  • 28,337
  • 7
  • 52
  • 74