I start a bat file "transfert.bat" by using a new process. It works but i would like t o cancel operation.
So what i did is to keep a reference to the launched process and then kill it.
By doing this, the process is not killed... the bat file still continues to transfert data.
Here is the snippet :
DataReceivedEventHandler handler = (s, e) => AsperaConnector_OnInformation(e.Data);
if (_process != null)
_process.OutputDataReceived -= handler;
_process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
WindowStyle = ProcessWindowStyle.Hidden,
FileName = "cmd.exe",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
Arguments = "/c" + transfertShellFilePath,
CreateNoWindow = true
_process.StartInfo = startInfo;
_process.OutputDataReceived += handler;
Code to kill :
Thanks for the help.