You are here:

C/executing any .exe file using 'C'

Advertisement


Question
Respected 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

Answer
Q1 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!  

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Prince M. Premnath

Expertise


I'm sure that I can solve any doubts in Turbo C ,Graphics Programing ,Mouse, Hardware Programming ,File System ,Interrupts, BIOS handling , TSR Programming , General Concepts in C Language, handling inline Assembly statements

Experience

Research over 6+ Years

Organizations
CG-VAK Softwares and Exports Limited

Education/Credentials
Masters in Computer Applications

©2012 About.com, a part of The New York Times Company. All rights reserved.