How can I edit an exe's resources (File Description, Icon, etc.) using a command line utility?
Asked Answered
C

3

9

The whole story: I have created a fancy .NET program which has an installer created by the Visual Studio Installer (VSI). The VSI creates 2 files (setup.exe and MyProgramSetup.msi). I understand the reasons for both files being needed, however, I only want to distribute a SINGLE executable installer to users. I do not want them to see 2 files and have to choose between them.

In order to do this I have merged the 2 files into a self-extracting archive using IExpress (as seen in this answer: Merge msi and exe). This works well, however, the self-extracting archive that gets created has an ugly icon and confusing file info (the File Description is "Win32 Cabinet Self-Extractor" with 43 blank spaces after it).

I need to replace the icon with my custom one and change some of the file properties like "Description", "Company", etc. I would like to have this automatically done as a build step so having a program which is a command line/console utility would be great.

I've searched for a while now and can only find one program which does exactly what I want (ResourceTuner Console: http://www.heaventools.com/command-line_resource_editor.htm) but it costs an arm and a leg and my budget is $0.

Does anyone know a better way to achieve what I want, or know of a program which can replace an executable's resources without having to use a GUI?

By the way, I have also tried SiComponents' Resource Builder 3 which can't even open the executable, and ResEdit which just crashes when I execute the command:

resedit.exe -convert "Modified Resources.rc" "MyProgramSetup.exe"
Cling answered 22/5, 2010 at 1:24 Comment(0)
H
8

Visual Studio can edit them if you open the executable file. I'm not sure if there's a way to do it from the command line, though.

There is a decent CodeProject article that deals with icons (including saving them into exe files).

Company name, description, etc., are part of the Version resource. Another CodeProject article covers updating the Version resource, though I haven't looked at that one in depth.

Hibiscus answered 22/5, 2010 at 2:35 Comment(1)
Your second link (VerPatch) was perfect for changing the version resources. Open source and only 93KB, excellent! I used the following command: verpatch.exe "Blah Setup.exe" /s CompanyName "Blah" /s FileDescription "Blah" /s InternalName "Blah" /s LegalCopyright "Blah" /s OriginalFilename "Blah"Cling
W
5

Answering just the file version information question, you may include your own version information in the IExpress .SED file. This site provides additional details on the IExpress .SED file sections and attributes. Using the built-on functionality seems easier than post-processing the setup exe.

Basically, in the .SED file, include the VersionInfo reference in the Options section. Then create the section containing your version info.

[Options]
VersionInfo=VersionSection

[VersionSection]
FromFile= ;Uses the version info in this executable file
; or specify each attribute 
; or specify the FromFile and override individual attributes
FileDescription=
CompanyName=
FileVersion=
ProductVersion=
OriginalFilename=
LegalCopyright=
ProductName=
InternalName=

BTW, the FileVersion does not work for me. YMMV,

Wilden answered 9/12, 2012 at 18:59 Comment(3)
I edit the sed files like this and Saved the changes , but modified details are not reflected on the final exe. Also do i need to share the sed file along with the exe to target machine to see the changes ?Koral
@JMat Did you add the .SED file to your Deployment Project. The .SED file is only used during by the build stage; no need to deliver that file.Wilden
The .sed file is generated by the IExpres wizard for me along with exe file . So its like we have to edit the sed file after generating the exe or am i doing it in the wrong order?Currently the steps i am doing are 1.generate exe and sed file using Iexpress tool and edit the sed file as per answer mentioned above and save changes. But the edit on sed files are not reflecting on exe file. My question here #28314304Koral
I
3

Have you looked at 'reshacker' AKA 'resource hacker'? It's mainly promoted as a gui tool, but the help file says all its features can be accessed using command line scripting. I've used its gui form to change icons inside exe's, and it will let you at the other embedded resources too. Just google for 'resource hacker', current version looks to be 3.4.0

Impatient answered 22/5, 2010 at 3:49 Comment(1)
I was able to use Resourse Hacker to replace the main icon using the following command: ResHacker.exe -addoverwrite "Blah Setup.exe", "Blah Setup.exe", "ProgramIcon.ico", ICONGROUP, MAINICON, 0Cling

© 2022 - 2024 — McMap. All rights reserved.