1
tempString = (string("cmd.exe /C \"") + tempString + "\"");

STARTUPINFO si = { sizeof(STARTUPINFO) };

PROCESS_INFORMATION pi;

CreateProcess(NULL, (LPSTR)tempString.c_str(), 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT, NULL, 0, &si, &pi);

I am starting a batch script from within another process through a dll. The issue is that the process is displaying:

error : Input redirection is not supported, exiting the process immediately.

How can I start a batch script so that it is independent of the calling process (will not close when callee closes) and does not output in the console of the calling process?

Kirill
  • 1,530
  • 5
  • 24
  • 48
John
  • 5,942
  • 3
  • 42
  • 79

2 Answers2

1

If you don't want show the console window when executing command string, you can do as below:

tempString = (string(" /C \"") + tempString + "\"");
ShellExecute(NULL, NULL, "cmd.exe", tempString.c_str(), NULL, SW_HIDE);
JerryYoung
  • 267
  • 1
  • 3
0

The CREATE_NEW_CONSOLE flag allocates a new console for the process to use so that it does not use the same stdout as the calling process.

John
  • 5,942
  • 3
  • 42
  • 79