John Doe John Doe - 1 year ago 187
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;


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 Source

Please try this:

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

Result should be:

"C:\Program Files\bin\install332.exe" remove tap0901
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download