I'm using the system
command in C++ to call some external program, and whenever I use it, a console window opens and closes after the command finishes.
How can I avoid the opening of a console window? I would be happy if the solution could be platform-independent. I would also like for my program to wait until the command is finished.
This is probably the easiest and maybe the best way, this will also make it so that your program doesn't freeze while running this command. At first don't forget to include the Windows header using;
#include <Windows.h>
Then you need to use the following function to run your command;
WinExec("your command", SW_HIDE);
Note; The WinExec
method has been deprecated for over a decade. It still works fine today though. You shouldn't use this method if not required.
... instead of the way you don't want to use;
system("your command");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With