Process.Start();Process.Kill();可以满足你的需求

解决方案 »

  1.   

    Process.Start();Process.Kill();可以满足你的需求
      

  2.   

    Process.Start("IExplore.exe", "C:\myPath\myFile.htm");
    Process.Kill();
      

  3.   

    foreach(System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses()) 
    {
    if(p.ProcessName.ToUpper() == "MyProgram")//MyProgram:应用程序名
    {
    p.Kill();
    }
      

  4.   

    foreach(System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses()) 
    {
    if(p.ProcessName.ToUpper() == "MyProgram")//MyProgram:应用程序名
    {
    p.Kill();
    }
      

  5.   

    Process.Start("IExplore.exe", "C:\myPath\myFile.htm");
    第一个参数和第二个参数分别代表什么意思呀?
      

  6.   

    第一个打开浏览器
    第二个运行的url
      

  7.   

    ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfsystemdiagnosticsprocessclassstarttopic.htm
    ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfsystemdiagnosticsprocessclasskilltopic.htm
      

  8.   

    Process.Start("IExplore.exe", "C:\myPath\myFile.htm");
    第一个参数代表程序,第二个为扩展。
    /// <summary>
    /// 执行单条命令
    /// </summary>
    /// <param name="commandText">命令文本</param>
    /// <returns>命令输出文本</returns>
    public static string ExeCommand(string commandText)
    {
    Process p = new Process();
    p.StartInfo.FileName = "cmd.exe";
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardInput = true;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.RedirectStandardError = true;
    p.StartInfo.CreateNoWindow = true;
    string strOutput = null;
    try
    {
    p.Start();
    p.StandardInput.WriteLine(commandText);
    p.StandardInput.WriteLine("exit");
    //string formats = s.Replace("\r","").Replace("\n","\r\n");
    strOutput = p.StandardOutput.ReadToEnd();
    p.WaitForExit();
    p.Close();
    }
    catch(Exception e)
    {
    strOutput = e.Message;
    }
    return strOutput;
    }
    /// <summary>
    /// 执行多条命令
    /// </summary>
    /// <param name="commandArray">命令文本数组</param>
    /// <returns>命令输出文本</returns>
    public static string ExeCommand(string [] commandTexts)
    {
    Process p = new Process();
    p.StartInfo.FileName = "cmd.exe";
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardInput = true;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.RedirectStandardError = true;
    p.StartInfo.CreateNoWindow = true;
    string strOutput = null;
    try
    {
    p.Start();
    foreach(string item in commandTexts)
    {
    p.StandardInput.WriteLine(item);
    }
    p.StandardInput.WriteLine("exit");
    strOutput = p.StandardOutput.ReadToEnd();
    p.WaitForExit();
    p.Close();
    }
    catch(Exception e)
    {
    strOutput = e.Message;
    }
    return strOutput;
    }
    /// <summary>
    /// 启动外部应用程序
    /// </summary>
    /// <param name="appName">应用程序路径名称</param>
    /// <returns>true表示成功,false表示失败</returns>
    public static bool StartApp(string appName)
    {
    bool blnRst = false;
    Process p = new Process();
    p.StartInfo.FileName = appName;//exe,bat and so on
    p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    try
    {
    p.Start();
    p.WaitForExit();
    p.Close();
    //while (!p.HasExited)
    //{
    // Thread.Sleep(1000);
    //}
    blnRst = true;
    }
    catch
    {
    }
    return blnRst;
    }
    /// <summary>
    /// 启动外部应用程序
    /// </summary>
    /// <param name="appName">应用程序路径名称</param>
    /// <param name="style">进程窗口模式</param>
    /// <returns>true表示成功,false表示失败</returns>
    public static bool StartApp(string appName,ProcessWindowStyle style)
    {
    bool blnRst = false;
    Process p = new Process();
    p.StartInfo.FileName = appName;//exe,bat and so on
    p.StartInfo.WindowStyle = style;
    try
    {
    p.Start();
    p.WaitForExit();
    p.Close();
    blnRst = true;
    }
    catch
    {
    }
    return blnRst;
    }
    /// <summary>
    /// 启动外部应用程序
    /// </summary>
    /// <param name="appName">应用程序路径名称</param>
    /// <param name="arguments">启动参数</param>
    /// <returns>true表示成功,false表示失败</returns>
    public static bool StartApp(string appName,string arguments)
    {
    bool blnRst = false;
    Process p = new Process();
    p.StartInfo.FileName = appName;//exe,bat and so on
    p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    p.StartInfo.Arguments = arguments;
    try
    {
    p.Start();
    p.WaitForExit();
    p.Close();
    blnRst = true;
    }
    catch
    {
    }
    return blnRst;
    }
    /// <summary>
    /// 启动外部应用程序
    /// </summary>
    /// <param name="appName">应用程序路径名称</param>
    /// <param name="arguments">启动参数</param>
    /// <param name="style">进程窗口模式</param>
    /// <returns>true表示成功,false表示失败</returns>
    public static bool StartApp(string appName,string arguments,ProcessWindowStyle style)
    {
    bool blnRst = false;
    Process p = new Process();
    p.StartInfo.FileName = appName;//exe,bat and so on
    p.StartInfo.WindowStyle = style;
    p.StartInfo.Arguments = arguments;
    try
    {
    p.Start();
    p.WaitForExit();
    p.Close();
    blnRst = true;
    }
    catch
    {
    }
    return blnRst;
    }