Add icon to existing EXE file from the command line [closed]
Asked Answered
D

4

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.

Duma answered 23/3, 2009 at 12:31 Comment(2)
+1 for RCEDIT.exe. Nothing to install and drop-dead simple.Marijo
you should post RCEDIT.EXE as accepted answer if that is what you ultimately went withAmil
S
16

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

Superheterodyne answered 23/3, 2009 at 12:45 Comment(0)
A
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).

Abstractionist answered 21/11, 2014 at 7:35 Comment(1)
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?Brag
S
16

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

Superheterodyne answered 23/3, 2009 at 12:45 Comment(0)
O
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.

Ontology answered 7/3, 2014 at 15:50 Comment(1)
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.Hoarfrost
B
2

Have you tried ResourceTuner Console?

Blather answered 23/3, 2009 at 12:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.