...id like something I could integrate into my build process: is there anything "standard" tool that does this?
-
1If you're doing this during the build process, why do you need to change the icon after the fact? Why not just build it with the correct icon in the first place? (See Ville Laurikari's answer). – Nick Meyer Jul 30 '09 at 17:47
-
See my comments in response to his answer. – jkp Jul 30 '09 at 17:50
-
1Sometimes it is needed to update version of file after actual build (insert SVN or CVS revision without source change). But I really can't see why do you need to change icon. – Kirill V. Lyadvinsky Jul 31 '09 at 04:33
4 Answers
Have you seen Resource Hacker? You can also drive it via the command line (script) so I'm sure it could be incorporated into your build.

- 13,510
- 9
- 44
- 50
-
I failed to replace the icons in a 7z self extracting exe file with Resource Hacker 4.2.5. There's two icons 1:0 2:0 and an icon group 101:0 in my exe file. I want to replace the icon data and keep the resource index untouched, which I think is the most straightforward way. According to my knowledge of PE format it is doable, but RH4.2.5 just can't do this. – fpemud May 05 '16 at 14:36
-
Unfortunately, Resource hacker v5.1.7 produces binary files that are somehow corrupt and can no longer be signed by `signtool.exe`. – cxxl Jan 07 '20 at 16:41
You need to create a resource script file (.rc
), and then compile it to an object file with rc
(.rc
→ .res
) and cvtres
(.res
→ .obj
). Both tools are included in the Microsoft Platform SDK. When you include the object file into an linker command, the result will have the icon specified in the resource script file. Here's a sample resource file and the commands to create the object:
resource.rc:
101 ICON "my_icon.ico"
Your icon file is in the file my_icon.ico
. Commands to compile these into an object file:
rc -fo resource.res resource.rc
cvtres -machine:ix86 -out:resource.obj resource.res
But, by far the easiest way to set the program icon is to just do it in Visual Studio.
Technically, neither will allow you to actually change the icon of an existing executable, but somehow I doubt that's what you really want to do.

- 1
- 1

- 28,380
- 7
- 60
- 55
-
2No no, I really do! The reason is convoluted: I need to add custom icons to some utilities I build using PyInstaller. The problem is the out of the box functionality relies on pywin32 which is OK, except that I run my build in a sandbox provided by `virtualenv` and `pip` in combination: unfortunately, I cannot find a way to get `pywin32` to install at all: there appears to be no way to get it to build in this environment. So to side-step the issue, I wanted to be able to change the icon after PyInstaller has done it's bit. – jkp Jul 30 '09 at 17:46
I am pretty sure Resource Hacker can do this, and some other things, I believe i recognize its icon from when i used it a while back. Hope that helps you!

- 2,804
- 6
- 32
- 41
-
Thats fantastic: and almost perfect, except I cant run it as part of my build process because it's not command line based. Upvote for an interesting link though. – jkp Jul 30 '09 at 17:44
-
I found this: http://www.heaventools.com/command-line_resource_editor.htm. Shame they want an inordinate amount of cash for it. – jkp Jul 30 '09 at 17:51
-
Its not a console application, but you can still run it with parameters and perform a single "action" without user interaction. It also supports script files if you need to perform several actions – Anders Aug 01 '09 at 08:00
Looks like I've found the perfect solution for what I'm trying to do.

- 78,960
- 28
- 103
- 104
-
1Unfortunately I later found it was not feature complete. Still with little effort someone could finish it off: it was only one `cpp` source file and the code was very clean. – jkp Jul 31 '09 at 07:56
-
I give up this tool because I don't want to install python for such a small job as icon changing. – fpemud May 05 '16 at 15:06