I need to pass a parameter with space while executing below batch script using createprocess. Tried to give " for parameter alone but not working.
std::wstring setupDir = L"\"D:\\Non Work\\New Bat File";
std::wstring ExecutablePath = L"\\Test.bat" ;
std::wstring toolsSetupPath = L"";
toolsSetupPath = L"CMD.exe /c " + setupDir +ExecutablePath +L"\" >C:\\AA 2.txt";
DWORD commandLineLength = (DWORD)toolsSetupPath.size() + 1;
LPWSTR process = (LPWSTR)_alloca(commandLineLength*sizeof(WCHAR));
wcscpy_s(process,
commandLineLength,
toolsSetupPath.c_str());
if (!CreateProcess(NULL, process, NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT, env,NULL, &si, &pi))
{
std::cout << "FAILURE" << std::endl;
std::cout << GetLastError();
system("pause");
abort();
}