zoukankan      html  css  js  c++  java
  • C# 重启exe

    休夸此地分天下
    c# 关闭和重启.exe程序
    Process[] myprocess = Process.GetProcessesByName("a");
    if (myprocess.Count() > 0)//判断如果存在
    {
    //myprocess[0].Kill();//关闭程序
    }
    else
    {
    try
    {
    Process newProcess = new Process();//创建一个新的进程
    ProcessStartInfo startInfo = new ProcessStartInfo();//启动进程时使用的集合
    //startInfo.FileName = Environment.CurrentDirectory + "\Release1\a.exe";//要启动的应用程序
    startInfo.FileName = "E:\work\Release\a.exe";//要启动的应用程序
    startInfo.WindowStyle = ProcessWindowStyle.Normal;//启动应用程序时使用的窗口状态
    //startInfo.WorkingDirectory = Environment.CurrentDirectory + "\Release1\";//要启动应用程序的路径
    newProcess.StartInfo = startInfo;//把启动进程的信息赋值给新建的进程
    newProcess.StartInfo.UseShellExecute = false;//是否使用操作系统shell执行该程序 
    newProcess.Start();
    }
    catch
    {
    //退出控制台程序
    Application.Exit();
    }
  • 相关阅读:
    leetcode319
    leetcode516
    leetcode46
    leetcode337
    leetcode287
    leetcode328
    leetcode241
    2018-6-30-dotnet-设计规范-·-抽象类
    2018-6-30-dotnet-设计规范-·-抽象类
    2018-8-10-WPF-如何画出1像素的线
  • 原文地址:https://www.cnblogs.com/wangchuang/p/9718290.html
Copyright © 2011-2022 走看看