I am trying to execute a cmd command from .NET and using the find cmd command as a pipe. But the find cmd command takes the value in string but when i am creating my string variable instead of taking double quotes it is replacing it with /"".
My string variable is "/c sc QUERY ServiceName | find \"START\"" and instead of passing "/c sc QUERY ServiceName | find "START"" this to cmd shell it is passing "/c sc QUERY ServiceName | find \"START\"" and my find command is failing.
Below is my .NET code
string cmdstr = "/c sc QUERY ServiceName | find \"START\"";
Process prc = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = cmdstr;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
prc.StartInfo = startInfo;
prc.Start();
string result;
result = prc.StandardOutput.ReadToEnd();
prc.WaitForExit(10);
When i debug the code the cmdstr value does not contain double quotes but it contains the \"