如何批量關(guān)閉系統(tǒng)進(jìn)程

字號(hào):


    //如何批量關(guān)閉某一進(jìn)程,用以下代碼可以實(shí)現(xiàn)(Ps:以下是.net代碼實(shí)現(xiàn)關(guān)閉php-cgi.exe進(jìn)程的方法)
    try
    {
    int num = 0;
    Process[] ps = Process.GetProcesses();
    foreach (Process item in ps)
    {
    if (item.ProcessName == "php-cgi")
    {
    if (num > 0)
    {
    item.Kill();
    }
    num++;
    }
    }
    }
    catch { }