You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Update
|
|
{
|
|
static class Program
|
|
{
|
|
/// <summary>
|
|
/// 应用程序的主入口点。
|
|
/// </summary>
|
|
[STAThread]
|
|
static void Main()
|
|
{
|
|
Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
var program = "PEIS.exe";
|
|
|
|
// 检查程序是否正在运行
|
|
Process[] processes = Process.GetProcessesByName(program);
|
|
|
|
if (processes.Length > 0)
|
|
{
|
|
// 关闭程序
|
|
foreach (var process in processes)
|
|
{
|
|
process.Kill();
|
|
process.WaitForExit(); // 等待程序退出
|
|
Console.WriteLine($@"Closed existing instance of {program}");
|
|
}
|
|
|
|
// 等待2秒
|
|
Thread.Sleep(1000);
|
|
}
|
|
Application.Run(new Form1());
|
|
}
|
|
}
|
|
}
|
|
|