Browse Source

Update UpgradeApp.cs

pull/5940/head
2dust 4 weeks ago
parent
commit
e6b1e22245
  1. 23
      v2rayN/AmazTool/UpgradeApp.cs

23
v2rayN/AmazTool/UpgradeApp.cs

@ -19,18 +19,15 @@ namespace AmazTool
return; return;
} }
Console.WriteLine("Try to end the process(尝试结束进程).");
try try
{ {
Process[] existing = Process.GetProcessesByName(V2rayN); var path = GetPath(V2rayN);
foreach (Process p in existing) Console.WriteLine(path);
{ var existing = Process.GetProcessesByName(V2rayN);
var path = p.MainModule?.FileName ?? ""; var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName == path);
if (path.StartsWith(GetPath(V2rayN))) pp?.Kill();
{ pp?.WaitForExit(1000);
p.Kill();
p.WaitForExit(100);
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -39,6 +36,7 @@ namespace AmazTool
"Close it manually, or the upgrade may fail.(请手动关闭正在运行的v2rayN,否则可能升级失败。\n\n" + ex.StackTrace); "Close it manually, or the upgrade may fail.(请手动关闭正在运行的v2rayN,否则可能升级失败。\n\n" + ex.StackTrace);
} }
Console.WriteLine("Start extracting files(开始解压文件).");
StringBuilder sb = new(); StringBuilder sb = new();
try try
{ {
@ -84,13 +82,12 @@ namespace AmazTool
} }
if (sb.Length > 0) if (sb.Length > 0)
{ {
Console.WriteLine("Upgrade Failed.\n" + Console.WriteLine("Upgrade Failed(升级失败)." + sb.ToString());
"(升级失败)." + sb.ToString());
return; return;
} }
Console.WriteLine("Start v2rayN, please wait...(正在重启,请等待)"); Console.WriteLine("Start v2rayN, please wait...(正在重启,请等待)");
Thread.Sleep(3000); Thread.Sleep(9000);
Process process = new() Process process = new()
{ {
StartInfo = new() StartInfo = new()

Loading…
Cancel
Save