After running the following code everything does as I would like except the folder shows this: test2﷽﷽ꮫꮫꮫꮫﻮﻮﻮ
What is going on here?
std::string arrString[3] = {" /C mkdir C:\\Users\\Andrew\\Desktop\\test1"," /C mkdir C:\\Users\\Andrew\\Desktop\\test2"," /C mkdir C:\\Users\\Andrew\\Desktop\\test3"};
LPWSTR cmd =L"C:\\Windows\\System32\\cmd.exe";
int i;
for(i=0; i<3; i++)
{
STARTUPINFO info={sizeof(info)};
PROCESS_INFORMATION processInfo;
vector<wchar_t> cmdline(arrString[i].begin(), arrString[i].end());
CreateProcessW(cmd, &cmdline[0], NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo);
OutputDebugStringW(L"My output\nstring.");
}
}
cmdlineis not properly ASCIIZ terminated. You can check if this is the cause just adding an ending 0 (note: not tested and a quick hack):