diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index da18f0cec9..813c3b9bf7 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -234,21 +234,7 @@ private void UpgradeN() { return; } - - Process process = new() - { - StartInfo = new ProcessStartInfo - { - FileName = "v2rayUpgrade", - Arguments = fileName.AppendQuotes(), - WorkingDirectory = Utils.StartupPath() - } - }; - process.Start(); - if (process.Id > 0) - { - Locator.Current.GetService()?.MyAppExitAsync(false); - } + Locator.Current.GetService()?.V2rayUpgrade(fileName); } catch (Exception ex) { diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index f5a110ad03..c11f60350d 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -428,6 +428,24 @@ public async Task MyAppExitAsync(bool blWindowsShutDown) } } + public async Task V2rayUpgrade(string fileName) + { + Process process = new() + { + StartInfo = new ProcessStartInfo + { + FileName = "v2rayUpgrade", + Arguments = fileName.AppendQuotes(), + WorkingDirectory = Utils.StartupPath() + } + }; + process.Start(); + if (process.Id > 0) + { + await MyAppExitAsync(false); + } + } + #endregion Actions #region Servers && Groups