C/Run an EXE file
Expert: Prince M. Premnath - 2/29/2008
QuestionQUESTION: Case:- Im my desktop, there is an ITQUE.EXE file.
Que:- I want to make a program in C language to Run this ITQUE.EXE file. Plz give me the program.
ANSWER: Hi Dear ashok !
A group of built- in functions are available to perform this task 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 .
Here what you supposed to do is to specify the correct path name ( where your .EXE file located in your system . ) as a second argument to the spawnl() function .
Please revert me in case of issues !
With Thanks and Regards !
Prince M. Premnath
---------- FOLLOW-UP ----------
QUESTION: Not working....
Program were running but not giving output of sample.exe.
My query is still to be Resolved
AnswerHi dear Ashok !
I didn't find any problem withis programme , here is an alternate solution of you ! If you are using Turbo C/C++ compiler then you can insert the function getch(); at the end to view the result in the same output window !
Note : Before executing the second programme "eg.c" make sure that you should already have an exe of sample.c ( say sample.exe ) if not load the programme sample.c onto the editor and compile and execute once it will create sample.exe !
Thanks and Regards !
Prince M. Premnath