I want run command line batch file with createprocessA().
Because I want run cmd line without visible.
I have to hide cmd window.
Here is my code:
PROCESS_INFORMATION pInfo;
FillMemory(&pInfo, sizeof(PROCESS_INFORMATION), 0);
STARTUPINFOA sInfo;
FillMemory(&sInfo, sizeof(STARTUPINFOA), 0);
sInfo.cb = sizeof(STARTUPINFOA);
sInfo.lpReserved = NULL;
sInfo.lpReserved2 = NULL;
sInfo.cbReserved2 = 0;
sInfo.lpDesktop = NULL;
sInfo.lpTitle = NULL;
sInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
sInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
sInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
sInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
sInfo.wShowWindow = SW_HIDE;
BOOL ret = ::CreateProcessA("c:\\windows\\system32\\cmd.exe", "c:\\windows\\shot.bat", NULL, NULL, FALSE, 0, NULL, NULL, &sInfo, &pInfo);
I tried it in cmd window like this.
cmd /c c:\\windows\\shot.bat
It works well but.
CreateProcessA() returns 1 and it does not take batch file action.
It does not work.
I need help.