How to change an executable's properties? (Windows)
If you are using C/Win32 you can add something like this to your project encapsulated in a *.rc (resource) file:
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,2
PRODUCTVERSION 0,0,0,2
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
{
BLOCK "StringFileInfo"
{
BLOCK "040904b0"
{
VALUE "Comments", "comment\0"
VALUE "CompanyName", "comment\0"
VALUE "FileDescription", "base file\0"
VALUE "FileVersion", "0.0.0.2 TP\0"
VALUE "InternalName", "testTP\0"
VALUE "LegalCopyright", "none\0"
VALUE "OriginalFilename", "test.exe\0"
VALUE "ProductName", "test\0"
VALUE "ProductVersion", "0.0.0.2 TP\0"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 1200
}
}
Modifying the Path to executable of a windows service
There is also this approach seen on SuperUser which uses the sc
command line instead of modifying the registry:
sc config <service name> binPath= <binary path>
Note: the space after binPath=
is important. You can also query the current configuration using:
sc qc <service name>
This displays output similar to:
[SC] QueryServiceConfig SUCCESS
SERVICE_NAME: ServiceName
TYPE : 10 WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
ERROR_CONTROL : 1 NORMAL
BINARY_PATH_NAME : C:\Services\ServiceName
LOAD_ORDER_GROUP :
TAG : 0
DISPLAY_NAME : <Display name>
DEPENDENCIES :
SERVICE_START_NAME : user-name@domain-name
How can I edit an exe's resources (File Description, Icon, etc.) using a command line utility?
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.
How to change the output name of an executable built by Visual Studio
- Open the Project Properties in Visual Studio (right click on project in Solution Explorer and select "Properties" from popup menu)
- On the "Application" tab of the properties window, change the "Assembly name"
I can change signed executable
I've never tried to do it. Yet when you edited the file, you invalidated the digital signature, you should see it in the Properties of the file.
Windows usually does not check digital signatures. Digital signatures come into play when the file is marked as downloaded from the Internet (if the signature is valid, Windows will show its publisher in the confirmation dialog; otherwise, the publisher will be unknown), and UAC (in this case, the digital signature also confirms the file came from a publisher stored as part of the digital signature).
Whether to show or not to show UAC confirmation is not controlled with digital signature, it's controlled with the application manifest.
So in my understanding, UAC dialog should be shown. But since the modified file fails digital signature check, Windows may decide the file is unsafe to elevate. You could look for messages in Windows event log, there could be events explaining the behavior you see.
Linux command line change Windows Executable Assembly Info
If I understand correctly, you want a hex editor, right?
On Linux you can install hexedit that would help you doing that.
Related Topics
Cross-Platform Equivalent to Windows Events
Virtual Destructor: Is It Required When Not Dynamically Allocated Memory
Aligned_Storage and Strict Aliasing
How to Use C Source Files in a C++ Project
Convert a Number to a String with Specified Length in C++
Qthread Emits Finished() Signal But Isrunning() Returns True and Isfinished() Returns False
Load Shared Library by Path at Runtime
Interfaces VS Templates for Dependency Injection in C++
Portable Branch Prediction Hints
In C++ I Cannot Grasp Pointers and Classes
Why Does the "Static" Keyword Have So Many Meanings in C and C++
Any Way Faster Than Pow() to Compute an Integer Power of 10 in C++
Using Zeromq Together with Boost::Asio
Why Use a "Tpp" File When Implementing Templated Functions and Classes Defined in a Header
Member Initializer Does Not Name a Non-Static Data Member or Base Class