Simple .exe program

Hi, i want to create an exe program that open other executables (a compiler and a linker for intel 8051 microprocessor)
The compiler is A8051.exe
The linker is Xlink.exe

A8051 must be opened as A8051.exe <programname> <programname> <programname>
Xlink as : Xlink -c8051 <programname>

The program has to require at the beginning the programname and send it as paramenter to the other two programs like shown above.

After that it has to copy the AOUT.A03 file the xlink will generate into <programname>.hex

This is what i ended up creating, partially working.


#include <windows.h>
#include <stdio.h>
#include <cstdlib>
#include <iostream>
int main ()
{
char* A8051 = "C:\\Documents and Settings\\XPMUser\\Desktop\\Prog\\A8051.exe";
char* Xlink = "C:\\Documents and Settings\\XPMUser\\Desktop\\Prog\\Xlink.exe -c8051";
WinExec(A8051,SW_SHOW);
WinExec(Xlink,SW_SHOW);
return EXIT_SUCCESS;
}


This is a pseudo of what i want to obtain:

#include <windows.h>
#include <stdio.h>
#include <cstdlib>
#include <iostream>
int main ()
{
std::cout<<"Write the name of the program"<<std::endl;
std::cin>>programname;

char* A8051 = "C:\\Documents and Settings\\XPMUser\\Desktop\\Prog\\A8051.exe <programname> <programname> <programname>";
char* Xlink = "C:\\Documents and Settings\\XPMUser\\Desktop\\Prog\\Xlink.exe -c8051 <programname>";
WinExec(A8051,SW_SHOW);
WinExec(Xlink,SW_SHOW);
copy AOUT.A03 <programname>.hex //cmd i know =D
return EXIT_SUCCESS;
}

EDIT : Forgot to mention i use C++, also is there any way i can incorporate the other 2 executables in this one and make them a single program? That would be epic
Last edited on
Hi,

First please use the code tags available when creating post in format options. As for the question I do not understand, can you remove the unnecessary code which just makes the question more confusing & next get to the point & tell us the question directly without creating massive chunks of irrelevant information.

However I do understand the EDIT: question. It is possible to incorporate 2 executables - in fact softwares similar to it exist called "file binders" these are however mainly used in malware to infect PCs via binding a malware executable to a legitimate file.

To get a deeper understanding of how "file binders" work I would advise you to read about PE file infection which requires the audience to have expert level knowledge on windows API & security in general. File binders are not a single file such as a single process or single handles but rather 2 file's machine code stored in one file with a CALL operation on each files entry point.

Therefore it is not exactly a single executable with 2 files codes because computer does not know vital information such as what file's code to run.
I don't understand what you find confusing.

I have for example the file program.txt. To compile it for a microprcessor i must open cmd prompt, get to the directory the file is and write A8051.exe program program program, after that i also do Xlink.exe -c8051 program. I get as output an AOUT.A03 wich i rename to program.hex.
This is so the whole procedure i have to do to get my hex file for the microprocessor.
I want to create myself an executable that does all this procedure asking me the filename only once.

The program will get the filename, pass is as parameter to the other executables i mentioned and automatically creates my file, simple as that.

http://i.imgur.com/mmOHNuO.jpg

So A8051.exe and Xlink.exe are other external executables i use and filename.txt is the file that those programs use to generate other files, as final output AOUT.A03.
Last edited on
You should write a simple batch script for this task, C++ does not seem the right tool for that (you can write it in C++ if you insist, of course)
Batch? like
@echo off
start "a8051" "<directory> etc?

You forgot you cannot use a variable parameter..
It is easy to make one for example if file is program.txt, but if i use a different one like programv2.txt i have to change the whole batch!

This is why i want a c++ program, it will ask for the name and change the parameters by itself
You forgot you cannot use a variable parameter..

Erm, yes you can... (exact syntax may be different, been a while since I wrote a batch file)

@echo off
set ARG1=%1
set ARG2=%2
echo %ARG1%
echo %ARG2%
http://msdn.microsoft.com/en-us/library/windows/desktop/ms687393(v=vs.85).aspx

Note This function is provided only for compatibility with 16-bit Windows. Applications should use the CreateProcess function.

Did you even look at what function you chose?
Made a working bat file for my purpose however there's only one big problem.
This program will also show errors in the code you wrote in the txt file if there are any, if you have a considerable amounts of errors it will scroll down but i'm unable to scroll back up to the upper part of the error list, it seems to forget lines after a certain numbers in order to be able to add new ones, how can i increase the number of lines a bat file can use?

http://i.imgur.com/4DZZYqt.jpg
Open up a cmd window, right-click the title bar, click "Properties", go to "Layout", and increase the height of the screen buffer size.

If you need more than 32766 lines, you may want to consider redirecting the output to a file instead of printing them to the screen.
Something like
myprog.exe command line arguments > myfile.txt 2>&1
(or, if you want to append to myfile.txt instead of replacing it, change the first > to a >>).
Topic archived. No new replies allowed.