Reputation: 8505
I have to start a process from my C++ code. I am using CreateProcess() function and I have set the following flags in the startupinfo struct. But still the command prompt shows up which I have to close manually to proceed. Please tell me how I can hide this command prompt during th e start up of the process.
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
the create process call looks like this:
CreateProcess( NULL, // No module name (use command line)
exe, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
CREATE_NEW_CONSOLE, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi );
exe is a string containing the process name to start.
Please tell me how to hide this command prompt during start up of the process. I tried the method described here but it doesn't work. I have a Windows 7 system.
Thanks, Rakesh.
Upvotes: 0
Views: 1300
Reputation: 6118
As MSalters says, the CREATE_NEW_CONSOLE
is not what you want. But you probably also want to pass CREATE_NO_WINDOW
to the CreateProcess
function. See the MSDN documentation on what you can pass to CreateProcess
as flags.
Upvotes: 1
Reputation: 179779
You're passing CREATE_NEW_CONSOLE
and you do NOT want a new console window. Seems like the answer is entirely obvious. Still, if the other process creates a console itself, then you cant prevent it. What happens if you start that process via Explorer?
Upvotes: 1