How do I pass a string with a double quote as a character as a command line argument?
The string basically has a space in between because of which it was getting treated as two different arguments. So I tried putting them in double quotes, like this.
wstring cmdLineParam = L"\"Test Value=abc\"";
This works perfectly fine in most of the cases. But now if I have a double quotes as a character in the string, it fails.
wstring cmdLineParam = L"\"Test Value=abc \"test me\"\"";// I want the string to be passed as Value=abc"test me"
Here the argument gets split into two arguments
argv[0] = "Test Value=abc test" argv[1] = "me"
This is my sample code.
wstring cmdLineParam = L"\"Test Value=abc \"test me\"\""; // Need to pass it as Value = abc "xyz uvw"
wstring path = L"C:\\cmdtest.exe";
BOOL bSuccess = CreateProcess ((LPCWSTR)path.c_str(), (LPWSTR)cmdLineParam.c_str(), NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &piProcess);
and as I mentioned, the output is
argv[0] = "Test Value=abc test"
argv[1] = "me"
Kindly guide
Thanks & Regards Sunil