MainModule FileName only exists in Win32.
This commit is contained in:
2dust
2024-11-03 13:44:12 +08:00
parent bb661d4f50
commit 4f05b93d63
3 changed files with 6 additions and 28 deletions
+5 -5
View File
@@ -22,12 +22,12 @@ namespace AmazTool
Console.WriteLine("Try to end the process(尝试结束进程).");
try
{
var path = GetPath(V2rayN);
Console.WriteLine(path);
var existing = Process.GetProcessesByName(V2rayN);
var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName.Contains(path) == true);
pp?.Kill();
pp?.WaitForExit(1000);
foreach (var pp in existing)
{
pp?.Kill();
pp?.WaitForExit(1000);
}
}
catch (Exception ex)
{