1

If I have two windows executables, am I able to combine them into one executable, and run them in sequence?

I tried doing this crudely and exactly, by using a simple program that read them both into one. The result was the second program was run, but the first program never was. Below I attempt to explain this better:

C:\> bind.exe a.exe b.exe >out.exe

b.exe is written after a.exe into out.exe If you look at out.exe it looks like a.exe THEN b.exe, written exactly in binary, including headers and other information that should not be repeated twice. Running it results in b.exe being run, while a.exe is NOT run. I tried switching the order like

C:\> bind.exe b.exe a.exe >out.exe

in which case a.exe was run.

Basically that method didn't work, so how should I go about doing this? I considered doing something with a hex editor while following format of this explanation of the windows PE format (the one used for windows executables) and removing the headers and such, but I feel like there is a less time consuming route to take.

Spenser Truex
  • 159
  • 1
  • 11
  • 1
    No, there's no way to do that. Closest you can get is a program that contains an embedded copy of the other two programs, and automatically extracts and runs them. – Harry Johnston Jul 05 '15 at 05:55
  • Why don't you just write a batch script that executes them in the proper sequence? – PC Luddite Jul 05 '15 at 05:56
  • @pcluddite I could do that but batch files look ugly, and using one would mean that I would need to have 3 files in a folder, instead of one autonomous file. So aesthetics. – Spenser Truex Jul 05 '15 at 06:05
  • @HarryJohnston You mean like a self extracting archive? – Spenser Truex Jul 05 '15 at 06:05
  • You don't need a batch file. From a command line type `a && b` - this runs `a` and if it succeeds runs `b`. For other options see http://ss64.com/nt/syntax-redirection.html – DavidPostill Jul 05 '15 at 10:55
  • @DavidPostill I am trying to make them into one single executable file. – Spenser Truex Jul 08 '15 at 06:46

1 Answers1

1

BATCH FILE

The easiest way is to use a batch file. And run one after the other.

RESOURCE FILE

Another way is to create a third exe and add the first two as resources to it. At run time, write the resources to a folder and run one after the other.

OTHER SOLUTIONS

Other suggestions are here

Merge two exe files into one programmatically

Community
  • 1
  • 1
Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41