Change the icon of an executable without recompiling or relinking and using command line tools from the microsoft sdk

StackOverflow https://stackoverflow.com/questions/22907051

  •  28-06-2023
  •  | 
  •  

Question

I need to change the icon of an already compiled and linked executable from the command line.

I can't do this in the build process, because this is just a tool in my builds and I don't want to recompile it every time I need to use it.

The executable is compiled and linked with an icon as a resource.

Other restriction is that the change must be done from the command line, so this step could be easily integrated in a build process.

Since I mainly use Microsoft compiler and linker, I was wondering if this can be achieved only by using the tools provided in the Microsoft SDK?

Additionally - I know that normally the change of resource would break any Digital Signature, is there a way to preserve the signature (this is only if possible, the change of the icon is more important). Any help will be much appreciated.

P.S: I know about ResourceHacker but it is of no use, because it doesn't have a command line interface.

Was it helpful?

Solution

See the function 'CopyIcon' here:

http://nullege.com/codes/show/src@p@y@pyinstaller-2.0@PyInstaller@utils@icon.py/181/win32api.EnumResourceNames

Basically it boils down do updating the icon resources in the compiled executable using UpdateResource()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top