我正在尝试与手刹的 cli 交互,但在需要时终止它的进程时遇到问题。
过程是这样开始的
string command = "/c \"C:\\Program Files\\Handbrake\\HandBrakeCLI.exe\" -i " + disk.Info.Name + " -o " + disk.Info.VolumeLabel + ".mkv -t " + titleNum + " -e x264 -q 18.0 -f mkv -4 --decomb --loose-anamorphic --modulus 2 -m --x264-preset medium --h264-profile high --h264-level 4.1";
_p = new Process();
_p.StartInfo = new ProcessStartInfo("cmd.exe", command)
{
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardError = true,
RedirectStandardOutput = true
};
_p.OutputDataReceived += OutputCallback;
_p.ErrorDataReceived += OutputCallback;
_p.Start();
_p.BeginErrorReadLine();
_p.BeginOutputReadLine();
_p.WaitForExit();
我试过用_p.Kill()
,_p.Close()
和终止_p.Dispose()
它_p.CloseMainWindow()
。最后一个有效,但仅当CreateNoWindow = false
.