Home  >  Article  >  Backend Development  >  C# kill background process

C# kill background process

黄舟
黄舟Original
2016-12-27 13:55:131757browse

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.

C# kill background process

The above is the content of killing the background process in C#. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn