var p = Process.GetProcessesByName("WINWORD"); if (p.Any()) { for (int i = 0; i < p.Length; i++) { p[i].Kill(); } } p = Process.GetProcessesByName("EXCEL"); if (p.Any()) { for (int i = 0; i < p.Length; i++) { p[i].Kill(); } }
When I first started, I didn’t know where ProcessName came from. I accidentally saw that the attribute name of the process was like this
As shown in the picture above, if you want to kill any process, just look at the name of the attribute of the process, which is the parameter value of GetProcessByName.
The above is the content of killing the background process in C#. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!