我有个例子,可以杀掉所有的IE.你可以参考以下:string ps="IExplore.exe";
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses();

foreach(System.Diagnostics.Process myProcess in myProcesses)
{
if ("IEXPLORE"==myProcess.ProcessName)        
myProcess.Kill();
   
}

解决方案 »

  1.   

    如何让Windows程序只运行一次?using System.Diagnostics;[STAThread]
    public static void Main(string[] args)
    {
    Process[] myProcesses = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName); 
        if(myProcesses.Length<=1) 
        Application.Run(new MainForm());
        else
        {
            MessageBox.Show("程序已经启动!","提示,MessageBoxButtons.OK,MessageBoxIcon.Exclamation); 
            Application.Exit(); 
    }
    }
      

  2.   

    不要打开两次程序 Dim brun As Boolean
    brun = (UBound(Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName)) > 0)
    If brun = True Then
    MessageBox.Show("程序已经运行,请不要打开两次!", "MAIN", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    Exit Sub
    Application.Exit()
    End if
    不要打开两次