I have C# program which finds the Drive Letter of the inserted USB and assign it to a variable _usbDriveLetter
.
I need to pass the value of _usbDriveLetter
to a batch file which further executes the CHKDSK _usbDriveLetter
command.
I have the following code to pass the value of _usbDriveLetter
and execute the batch file.
string _usbDriveLetter = @"F:\"; //For testing here
string MyBatchFile = @"<FILEPATH>\chkdsk.cmd";
ProcessStartInfo proc = new ProcessStartInfo();
proc.CreateNoWindow = true;
proc.FileName = MyBatchFile;
proc.Arguments = usbDriveLetter ;
Process.Start(proc);
Question: As soon as the code reach the line to execute the batch, the following window appear to allow the CMD.exe to start. How can I make the execution in background/Silent (at least without any user interaction).