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.
In the Resource Hacker window, select the “Icon” folder in the left pane. Click the “Action” menu and then select “Replace Icon.” In the Replace Icon window, click the “Open file with new icon” button and browse to the location of the icon you want to use. The source can be an EXE, DLL, RES, or ICO file.
To change the icon that the .exe has, you can pass the --icon=icon. ico to the pyi-makespec command or modify the . spec file yourself by altering the exe object to add the argument icon='icon.
Type "start [filename.exe]" into Command Prompt, replacing "filename" with the name of your selected file. Replace "[filename.exe]" with your program's name. This allows you to run your program from the file path.
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).
Resource Hacker is a free tool that allows you to modify resources in executables, and it can be scripted from the command line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With