Click to See Complete Forum and Search --> : Launch of BAT File


eolson
June 14th, 2003, 09:21 PM
Hello,
I wonder if it is possible to launch a batch file (.BAT) from a simple C++ program (just a Main() application). It is possible to launch DOS command too, and keep the result as a char* ??

Plz, it is very important !!

Andreas Masur
June 15th, 2003, 05:33 AM
Originally posted by eolson
Hello,
I wonder if it is possible to launch a batch file (.BAT) from a simple C++ program (just a Main() application).

Take a look at the following FAQ (http://www.codeguru.com/forum/showthread.php?s=&threadid=231233)...

Originally posted by eolson
It is possible to launch DOS command too, and keep the result as a char* ??

Take a look at the 'system()' function...

eolson
June 15th, 2003, 12:56 PM
Wonderfull

system(), it's exactly this kind of API I looked for. Moreover it's AINSI compatible !! But I have no access to the MSDN library yet, and I have not found how to recuperate the output of the launched command (for exemple, the result of "dir" ) ?? Anybody have an idea ??

Thanks a lot Andreas .

Andreas Masur
June 15th, 2003, 04:49 PM
system("dir > c:\\test\\result.txt");

eolson
June 16th, 2003, 04:24 PM
Yes, it's what I did, but I would like to know a method without writting tmp file ....
But thank you a lot for your help.

Andreas Masur
June 16th, 2003, 04:48 PM
Well...you need to specify what you are trying to accomplish. If you want to display the results in your program, I would rather suggest different methods than using 'system()'...for example take a look at this FAQ (http://www.codeguru.com/forum/showthread.php?s=&threadid=231184)...