John Doe John Doe - 9 days ago 5
C# Question

C# Executing CMD command with quotation mark in string

I want to execute the following cmd command:

"C:\Program Files\bin\install332.exe" remove tap0901


This is my code in C#:

ProcessStartInfo Install332= new ProcessStartInfo();
path Install332.FileName = ("cmd.exe");
//Our cmd code
Install332.Arguments = (""C:\Program Files\bin\install332.exe" remove tap0901"");

Install332.WindowStyle = ProcessWindowStyle.Hidden;
Install332.CreateNoWindow = true;

Process.Start(Install332);


But the cmd command won't execute properly since the quotation mark in the cmd command which specifies the "install332.exe" location don't appear. I appreciate any help.

Answer

Please try this:

string path = "\"C:\\Program Files\\bin\\install332.exe\" remove tap0901";
Console.WriteLine(path);

Result should be:

"C:\Program Files\bin\install332.exe" remove tap0901