views:

77

answers:

2

How can I load the batch file console to my C console?

I know in batch The command is Showme.bat /B and it'll load the console into whatever console you called that file from.

What would that be in C?

ShellExecute(NULL,"open","Showme.bat",NULL,NULL,SW_SHOW); 

Also, doing that... How could I also add additional arguments such as

>>LogTheConsoleTo-a-File.log

Is that possible?

A: 

I figured it out but I still cannot keep writing to the same file.

Here's what I did: ShellExecute(NULL,"open","Showme.bat",">>consoleLog.log",NULL,SW_SHOW);

Kyle
If you answer your own question, it's nice to say *how* you figured it out so that future readers will learn something, too :)
Philip Potter
Good idea. I added what I did
Kyle
+1  A: 

Use the POSIX function "popen". With MSVC/MinGW you can use "_popen" instead. This give you the needed control.