Running a batch file from C++

Nov 1, 2010 at 2:14am
In my program I have the ofstream create a batch file, what I want C++ to do is to start it. So far I have been using system(), but as we all know shouldn't use that. Does anyone even know how to start/run a batch file from C++?
Nov 1, 2010 at 2:55am
You can use system() to start your batch file...

if (system( "foo.bat" )) fooey();

Hope this helps.
Nov 1, 2010 at 3:01am
I've been using that, but I want to know if there is an alternative or not?
Nov 1, 2010 at 3:17am
Yes, there is a Windows-specific function: CreateProcess().
http://www.google.com/search?btnI=1&q=msdn+CreateProcess

It is a bit unwieldly just to run a batch file...
Nov 1, 2010 at 6:51am

Thanks you for the post.






Topic archived. No new replies allowed.