I want to run cmd command:"net use * /delete" with System.Diagnostics.Process,but the command needs to input "Y" or "N".
here is my code:
Process proc = new Process();
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
string dosLine = "/C echo y | net use * /delete";
proc.StartInfo.Arguments = dosLine;
proc.Start();
the codes do not work. i also tried this:
proc.StandardInput.WriteLine("net use * /delete");
proc.StandardInput.WriteLine("Y");
still not work
what should i do?