cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
user name:
password:
Forgot your password?
please wait
try again
cancel
forgot your password?
sign up
log in
[Legacy version]
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Running a batch file from C++
Running a batch file from C++
Nov 1, 2010 at 2:14am
Nov 1, 2010 at 2:14am UTC
LittleQuick
(84)
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
Nov 1, 2010 at 2:55am UTC
Duthomhas
(13277)
You can use
system
() to start your batch file...
if
(system(
"foo.bat"
)) fooey();
Hope this helps.
Nov 1, 2010 at 3:01am
Nov 1, 2010 at 3:01am UTC
LittleQuick
(84)
I've been using that, but I want to know if there is an alternative or not?
Nov 1, 2010 at 3:17am
Nov 1, 2010 at 3:17am UTC
Duthomhas
(13277)
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
Nov 1, 2010 at 6:51am UTC
kellyj994
(1)
Thanks you for the post.
Topic archived. No new replies allowed.