larynx Posted January 18, 2008 Share Posted January 18, 2008 I'm using Visual C# (within Visual Studio 2005) to code something and I'm looking for way a to include an existing exe file within the project so I can run it within the program I'm creating, the idea is that I end up (after the build) with one exe file that does something and also executes the other exe file. Is there anyway to do this? If not, is there a good alternative? Thanks in advance... Quote Link to comment Share on other sites More sharing options...
digip Posted January 18, 2008 Share Posted January 18, 2008 Use an exe wrapper? Or embed a file in the program using OLE and then extract and execute against the file. Quote Link to comment Share on other sites More sharing options...
sablefoxx Posted January 18, 2008 Share Posted January 18, 2008 What i have seen done, i have not done this myself, but what you can do is take the .exe binary > a oct array and when it runs write it back out in binary. Quote Link to comment Share on other sites More sharing options...
natural_orange Posted March 6, 2008 Share Posted March 6, 2008 you should be able import it into a resource file and then use the io.file.copy feature to copy it back out to the computer. Quote Link to comment Share on other sites More sharing options...
deleted Posted March 6, 2008 Share Posted March 6, 2008 If you mean run both programs from one EXE, you can use iexpress with come with windows. Quote Link to comment Share on other sites More sharing options...
digip Posted March 7, 2008 Share Posted March 7, 2008 If you mean run both programs from one EXE, you can use iexpress with come with windows. Yeah, if you want to install multiple exe's at a time and script the install process into one package. Quote Link to comment Share on other sites More sharing options...
dejai Posted March 20, 2008 Share Posted March 20, 2008 system("my.exe"); would run my.exe in the same folder as the original .exe its not to hard :D Quote Link to comment Share on other sites More sharing options...
Xqtftqx Posted April 11, 2008 Share Posted April 11, 2008 use iexpress, put 2 exe in a folder with a batch file start 1.exe start 2.exe and compile it Quote Link to comment Share on other sites More sharing options...
hexlax Posted April 21, 2008 Share Posted April 21, 2008 Check out episode 3x09. They discuss how you can accomplish this with iexpress and some other commercial software. Quote Link to comment Share on other sites More sharing options...
dejai Posted May 5, 2008 Share Posted May 5, 2008 I am quite sure he is not trying to package the file. I think he wants to run a .exe from within a .exe.. You can't "Include" a .exe binary in a source file. The reason? Because it is not the original source it has been compiled, boiled down. You would need the source. Correct me if I am wrong but you would either have to decompile it or use its original source in compilation.. If you want to run a .exe from within a .exe with C++ : system("my.exe"); Quote Link to comment Share on other sites More sharing options...
nicatronTg Posted May 8, 2008 Share Posted May 8, 2008 I am quite sure he is not trying to package the file. I think he wants to run a .exe from within a .exe.. You can't "Include" a .exe binary in a source file. The reason? Because it is not the original source it has been compiled, boiled down. You would need the source. Correct me if I am wrong but you would either have to decompile it or use its original source in compilation.. If you want to run a .exe from within a .exe with C++ : system("my.exe"); You could open the program in notepad, then copy the program into c#, and put it in an array. Then write the array back out using a file stream. I shall prove with a program... Quote Link to comment Share on other sites More sharing options...
sbtUK Posted May 29, 2008 Share Posted May 29, 2008 I'm not much of a coder (other than the odd bit of php) so I don't know for sure but... Could you fork one exe into an alternate data stream of the other? Who knows?! :-P I might do a bit of experimenting later on when I've finished doing more important stuff like drinking my coffee. Drinking coffee is very important. Quote Link to comment Share on other sites More sharing options...
Steve8x Posted June 13, 2008 Share Posted June 13, 2008 You could open the program in notepad, then copy the program into c#, and put it in an array. Then write the array back out using a file stream. I shall prove with a program... Yes nicatronTg is exactly right! you don't need source code to run a binary executable... lolz dejay or whatever your name is, you are 100% wrong!!! why on earth would you need source code to embed binary data in an executable program of your own? nicatronTg I thought you were going to post an example program? I guess you forgot! well I'll do it... okay I whipped up this program in 5 minutes! its really simple, I use this method all the time when making my directx games, I like to embed the textures and sounds and all that good stuff within the executable file it self that way I dont leave things in a folder somewhere for someone to mess with... its all hidden inside the games executable where noobs wont even mess with... I use Hex Workshop to take a file's bytes and format it in an unsigned char array that is ready to copy and paste right into your source code(I like to make a header file to store the binary data as it is a huge array even with a small file, so instead of making the main source code a difficult to scroll through file I just put it in a header file and keep my source code file clean) in hex workshop goto Edit->select all, then Edit->Copy As-> C Source In this example I will be using calc.exe just to demonstrate exactly how easy this is... Im using Microsoft Visual C++ 2008 by the way(you might have to modify it slightly to work for other compilers) Ok I have created a blank console project(I hate the precompiled header) then added a .cpp called "ExeInExe.cpp" then I wrote this code: yeah I just had to post because DJ said it was not possible without source code LOL !! :P #include <windows.h> // all required headers #include <stdio.h> #include <fstream> #include <iostream> #include "CalcData.h" // where the binary data for "calc.exe" is stored using namespace std; char EXEfile[256]; // will hold the path to the executable to run once extracted from this console executable int main() { SetConsoleTitleA("Steves Embed File Into Executable Example"); system("color 0A"); GetSystemDirectoryA(EXEfile, 256); // get system dir to hide exe file ex. C:\WINDOWS\system32 strcat_s(EXEfile, "\\secret"); // append our secret dir CreateDirectoryA(EXEfile, 0); // create the folder strcat_s(EXEfile, "\\EmbeddedCalc.exe"); // concatenate file name to it so we save the exe into this new folder ofstream EXE(EXEfile, ios::binary); // create the file at the specified secret path ios::binary for binary data EXE.write((char*)&Calc, sizeof(Calc)); // write the calc binary data to the file EXE.close(); // save and close the file cout << "Saved EXE file to: " << EXEfile << "\n"; // print out where it was saved to console cout << "Running exported exe file in\n\n"; for(int x = 3; x > 0; x--) // count down 3 2 1 RUN!!! // count down to execution { cout << x << "...\n"; Sleep(1000); } // finally use shellexecute to execute the file, better than system() ShellExecuteA(0, "open", EXEfile, 0, 0, SW_SHOWNORMAL); // or you could use SW_HIDE to create the window hidden hehe! :) cout << "\n\n\n\n"; system("pause"); return 0; } CalcData.h is way to big to post here so ive gone ahead and uploaded the whole project to this link: http://rapidshare.com/files/122239169/ExeInExe.rar.html or you can just use hex workshop and make it yourself from calc, and change the name of the unsigned char array to "Calc" Thats how its done :) Quote Link to comment Share on other sites More sharing options...
Steve8x Posted June 13, 2008 Share Posted June 13, 2008 LOL notice the number of views for this thread, no I didn't edit the image thats just what it was! a fluke! Quote Link to comment Share on other sites More sharing options...
moonlit Posted June 13, 2008 Share Posted June 13, 2008 * Moonlit scowls. Quote Link to comment Share on other sites More sharing options...
Steve8x Posted June 13, 2008 Share Posted June 13, 2008 You scowl at my post? there isn't anything wrong with my code! right? *Steve8x Smiles Quote Link to comment Share on other sites More sharing options...
mikky Posted May 19, 2010 Share Posted May 19, 2010 Hi all! Can anyone re-upload this ? http://rapidshare.com/files/122239169/ExeInExe.rar.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.