I have a fairly simple question, which may or may not have a simple solution. How can I run the system(); command, in a win32 (not console) application, without the black command prompt window flashing on the screen?

If relevant, I am using Dev-C++.

9 Years
Discussion Span
Last Post by Murtan

The short answer is that you can't. The system() function (it's not a command) supported by win32 compilers/libraries starts up a command shell, and that command shell shows the "black command prompt window".

If you actually need a command shell (eg you're running an inbuilt shell command or executing a .BAT file), then you have no choice. However, you might be able to find a way to implement your required functionality without using a command shell.

If you want to run a third-party program (eg another win32 application) with more control than is possible with the system() command, look up the CreateProcess() function in the win32 API.


I agree with grumpier, if you have to use the system() call, you're stuck with the "black window". But unless you're calling batch files, you can probably avoid the system() call.


I know, system() isn't a command, I was in a hurry when I wrote that.

Well, basically what I'm trying to do is make a program that automatically starts the user in the SYSTEM account (if you've seen guides on how to do that). It's not a particularly "useful" program, but it's good practice. I am trying to use the "at" command using /interactive to start explorer.exe as SYSTEM.


std::string cmd = "at " + calcTime(1) + " /interactive explorer.exe";

Perhaps this is was a stupid question, I suppose I could use CreateProcess() to run at.exe. Am I correct?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.