From 1c95c5861c38cb588ef2b26d2c9404232291f080 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 2 Jan 2023 11:01:43 +0800 Subject: [PATCH] Fix startup issues --- v2rayN/v2rayN/Tool/Utils.cs | 14 +++++++++++--- v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/v2rayN/v2rayN/Tool/Utils.cs b/v2rayN/v2rayN/Tool/Utils.cs index bb9382cc..060f7b58 100644 --- a/v2rayN/v2rayN/Tool/Utils.cs +++ b/v2rayN/v2rayN/Tool/Utils.cs @@ -597,13 +597,21 @@ namespace v2rayN { try { - string exePath = GetExePath(); - RegWriteValue(Global.AutoRunRegPath, Global.AutoRunName, run ? $"\"{exePath}\"" : ""); + var autoRunName = $"{Global.AutoRunName}_{GetMD5(StartupPath())}"; + + //delete first + RegWriteValue(Global.AutoRunRegPath, autoRunName, ""); + + if (run) + { + string exePath = $"\"{GetExePath()}\""; + RegWriteValue(Global.AutoRunRegPath, autoRunName, exePath); + } } catch (Exception ex) { SaveLog(ex.Message, ex); - } + } } /// diff --git a/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs b/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs index da1f85f2..7c84cd01 100644 --- a/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs @@ -125,7 +125,7 @@ namespace v2rayN.ViewModels #endregion #region UI - AutoRun = Utils.IsAutoRun(); + AutoRun = _config.autoRun; EnableStatistics = _config.enableStatistics; StatisticsFreshRate = _config.statisticsFreshRate; KeepOlderDedupl = _config.keepOlderDedupl; @@ -282,6 +282,7 @@ namespace v2rayN.ViewModels //UI Utils.SetAutoRun(AutoRun); + _config.autoRun = AutoRun; _config.enableStatistics = EnableStatistics; _config.statisticsFreshRate = StatisticsFreshRate; if (_config.statisticsFreshRate > 100 || _config.statisticsFreshRate < 1)