C/executing any .exe file using 'C'
Expert: Prince M. Premnath - 10/6/2006
QuestionRespected Sir,
Ques1- I want the code with logic, to execute any .exe file.
Ques2- How can i run my program before booting or with booting
AnswerQ1 A group of built- in functions are available to perform this task
eg: suppose you are working in c:\tc directory , and you wish to execute a EXE file named "sample.exe"
just use the "spawnl()" function available in process.h header file
FILE : sample.c
void main()
{
printf("Sample .c Program\n");
}
/* save and compile the file */
FILE: EG.C
void main()
{
spawnl(P_WAIT , "sample.exe" , NULL);
printf("This is from eg");
}
The output of eg.c will be:
sample.c Program
This is from eg
this simple C program will execute your sample.exe program and return control to the main program .
Q2.
This is bit very difficult !
You should have a loader program that loader program will in turn load your program just after you ON your system
That loader program should be written into the Boot Parameter Block of the booting medium( say floppy or HDD )
( This is simple this can be done by a utility "bootable.exe" )
After finishing this your program will be loaded and executed after switching ON your computer ( it wll just act like OS)
NOTE : No other os can be loaded later .
( for convinience just do all things ina floppy and boot your system from 'A' drive )
Thank you!