From bd838094cd411d0f1bbc5f739e7d3f4d83ef8538 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 27 Jan 2024 18:29:17 +0800 Subject: [PATCH] bug fix --- v2rayN/v2rayN/Common/StringEx.cs | 10 ++++++++++ v2rayN/v2rayN/Handler/UpdateHandle.cs | 4 ++-- v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/v2rayN/v2rayN/Common/StringEx.cs b/v2rayN/v2rayN/Common/StringEx.cs index 57ba7795..9a751ce9 100644 --- a/v2rayN/v2rayN/Common/StringEx.cs +++ b/v2rayN/v2rayN/Common/StringEx.cs @@ -80,5 +80,15 @@ namespace v2rayN return char.ToUpper(value[0]) + value.Substring(1); } + + public static string AppendQuotes(this string value) + { + if (string.IsNullOrEmpty(value)) + { + return string.Empty; + } + + return $"\"{value}\""; + } } } \ No newline at end of file diff --git a/v2rayN/v2rayN/Handler/UpdateHandle.cs b/v2rayN/v2rayN/Handler/UpdateHandle.cs index 6236c58f..d7d977a2 100644 --- a/v2rayN/v2rayN/Handler/UpdateHandle.cs +++ b/v2rayN/v2rayN/Handler/UpdateHandle.cs @@ -54,7 +54,7 @@ namespace v2rayN.Handler StartInfo = new ProcessStartInfo { FileName = "v2rayUpgrade.exe", - Arguments = $"\"{fileName}\"", + Arguments = fileName.AppendQuotes(), WorkingDirectory = Utils.StartupPath() } }; @@ -364,7 +364,7 @@ namespace v2rayN.Handler } using Process p = new(); - p.StartInfo.FileName = filePath; + p.StartInfo.FileName = filePath.AppendQuotes(); p.StartInfo.Arguments = coreInfo.versionArg; p.StartInfo.WorkingDirectory = Utils.StartupPath(); p.StartInfo.UseShellExecute = false; diff --git a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs index c0122284..96c26562 100644 --- a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs @@ -1388,7 +1388,7 @@ namespace v2rayN.ViewModels UseShellExecute = true, Arguments = Global.RebootAs, WorkingDirectory = Utils.StartupPath(), - FileName = Utils.GetExePath(), + FileName = Utils.GetExePath().AppendQuotes(), Verb = "runas", }; try