Quoting the whole argument with an extra quotes, does not work.
char command[256] = R"(""D:\src has space" "E:\dest has space" /I /Y /E")";
auto process = CreateProcessA(
//"Project1.exe", //my test program below
R"(C:\Windows\system32\xcopy.exe)",
command,
nullptr,
nullptr,
true,
CREATE_NO_WINDOW,
nullptr,
".",
&si, &pi
);
I got Invalid number of parameters
.
I wrote a little program to print out the arguments, one by one and then showing in a messagebox.
#include <windows.h>
#include <string>
int main(int argc, char** argv)
{
std::string s = std::string{"argc = "} + std::to_string(argc);
s += '\n';
for (int i = 0; i<argc; ++i)
{
(s += argv[i]) += '\n';
}
MessageBoxA(NULL, s.data(), "Caption", 0);
}
This is obviously not correct.
Removing the extra quotes does not work either
char command[256] = R"("D:\src has space" "E:\dest has space" /I /Y /E)";