open application in hidden mode
-
hi, I am running an application with ShellExecute() but not able to run in hidden mode ShellExecute(NULL,_T("open"),_T("myapp.exe"),szCommandLineParameter,szTargetDirectoryPath,SW_HIDE); SW_HIDE - Hide command line . What is wrong?
Is it a cosole application? Try using
CreateProcess
instead withSTARTF_USESHOWWINDOW
in thedwFlags
member ofSTARTUPINFO
andSW_HIDE
in itswShowWindow
member.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
What type of exe you are using...?
-
hi, I am running an application with ShellExecute() but not able to run in hidden mode ShellExecute(NULL,_T("open"),_T("myapp.exe"),szCommandLineParameter,szTargetDirectoryPath,SW_HIDE); SW_HIDE - Hide command line . What is wrong?
What type of exe you are using...?
-
Is it a cosole application? Try using
CreateProcess
instead withSTARTF_USESHOWWINDOW
in thedwFlags
member ofSTARTUPINFO
andSW_HIDE
in itswShowWindow
member.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
In that case, the solution that I gave using
CreateProcess
will work.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
In that case, the solution that I gave using
CreateProcess
will work.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
I tried this again and it works perfectly.
wchar_t szCommand[] = L"C:\\Windows\\System32\\Cmd.exe";
STARTUPINFO si;
::ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;PROCESS_INFORMATION pi;
::CreateProcess(0, szCommand, 0, 0, 0, 0, 0, 0, &si, &pi);
«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
I tried this again and it works perfectly.
wchar_t szCommand[] = L"C:\\Windows\\System32\\Cmd.exe";
STARTUPINFO si;
::ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;PROCESS_INFORMATION pi;
::CreateProcess(0, szCommand, 0, 0, 0, 0, 0, 0, &si, &pi);
«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)yes this will hide the command prompt but what about the other application which will launch through command prompt.
wchar_t szCommand[] = L"-m -l";//command line parameter for application
STARTUPINFO si;
::ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;PROCESS_INFORMATION pi;
::CreateProcess(_T("myapp.exe"), szCommand, 0, 0, 0, 0, 0, 0, &si, &pi);
-
First try with SW_SHOWNORMAL mode. if it is working fine then try with SW_HIDE. If it is also not working then check the exe path and command line arguments. Is it running in normal mode when you using SW_HIDE argument...?
-
yes this will hide the command prompt but what about the other application which will launch through command prompt.
wchar_t szCommand[] = L"-m -l";//command line parameter for application
STARTUPINFO si;
::ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;PROCESS_INFORMATION pi;
::CreateProcess(_T("myapp.exe"), szCommand, 0, 0, 0, 0, 0, 0, &si, &pi);
JM2251 wrote:
yes this will hide the command prompt but what about the other application which will launch through command prompt.
You're correct: Cmd is hidden but the app it's executing not. Some solutions: - create a shortcut to the exe and run that one. In the shortcut you can set options to hide it. - If it is a console app you could route the display output to a NULL device (example: Dir > null). See createprocess options. Hope this helps