There is a command for cmd (launching the process on behalf of the system), writing the given code for the ProcessStartInfo argument as a string does not work, it is possible to convert a string (with no syntax checking) into something with the subsequent possibility of using it as a string at the right time.

CMD Example

cmd /c sc create -- binPath= "cmd /c start \"\" \"C:\Windows\regedit.exe\" " type= own type= interact & net start -- & sc delete -- 

    1 answer 1

    In order for the compiler not to pay attention to the contents of the line, you can use the following syntax:

     string path = @"c:\windows\system32\"; 

    Escaping slashes in this case is not required. But to insert, for example, the transfer of the string \n also does not work, or rather, it will not be treated as a control character.

    Double quotes are worse. Because they are part of the syntax of the language and require mandatory escaping \" , which is not combined with @ . In this case, you can insert them using a symbolic constant in the form of the code '\u0022' , or escape quotes by doubling:

     string cmd = @"notepad.exe ""c:\My docs\draft.txt"" "; 

    Microsoft's recommendations and examples of double quotes can be found here (this link does not indicate the option of quoting double-quotes)

    • one
      quotes are escaped with quotes, that is, they just need to be doubled - Mirdin
    • I didn’t know thanks, really works with the "dog" ... now I will correct it - rdorn
    • textBox1.Text = @ "She said," "You deserve a treat!" ""; - Mirdin
    • @Mirdin yeah, overlooked however - rdorn