修复虚拟网卡添加路由错误,和增加自动更新

This commit is contained in:
snltty
2024-07-17 22:48:31 +08:00
parent 23ab89842f
commit 43f99c311b
2 changed files with 9 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ namespace linker.service
protected override void OnStart(string[] _args) protected override void OnStart(string[] _args)
{ {
CheckMainProcess(); CheckMainProcess();
} }
protected override void OnStop() protected override void OnStop()
{ {

View File

@@ -272,24 +272,24 @@ namespace linker.plugins.updater
private void StartClearTempFile() private void StartClearTempFile()
{ {
bool restart = false;
if (OperatingSystem.IsWindows()) if (OperatingSystem.IsWindows())
{ {
Process[] trays = Process.GetProcessesByName("linker.tray.win"); Process[] trays = Process.GetProcessesByName("linker.tray.win");
restart = trays.Length > 0; if (trays.Length > 0)
foreach (var tray in trays)
{ {
tray.Kill(); foreach (var tray in trays)
{
tray.Kill();
}
CommandHelper.Windows(string.Empty, new string[] { "start linker.tray.win.exe --task=1" });
} }
CommandHelper.Windows(string.Empty, new string[] { "sc stop linker.service" });
} }
ClearTempFile(); ClearTempFile();
if (restart && OperatingSystem.IsWindows()) if (File.Exists("linker.service.exe.temp"))
{ {
CommandHelper.Execute("linker.tray.win.exe", "--task=1"); CommandHelper.Windows(string.Empty, new string[] { "sc stop linker.service & sc start linker.service" });
CommandHelper.Windows(string.Empty, new string[] { "sc start linker.service" });
} }
} }
private void ClearTempFile(string path = "./") private void ClearTempFile(string path = "./")