From 0178ace8306fcc3f52dcd05e621abc312f80fe2c Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Sat, 6 Jan 2024 14:31:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E6=97=A7=E7=89=88.cmd=E5=90=AF=E5=8A=A8=E5=90=8E=E4=B8=8B?= =?UTF-8?q?=E6=AC=A1=E6=9B=B4=E6=96=B0=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/UI/VersionUpdateViewModel.cs | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs b/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs index 57c4614293..b1f9d9f49d 100644 --- a/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs @@ -224,13 +224,15 @@ namespace MaaWpfGui.ViewModels.UI // 如果是 Framework48,把 MAA.exe 复制一份,重命名为 MAA_win7.exe if (RuntimeInformation.FrameworkDescription.Contains("Framework")) { - File.Copy(Path.Combine(curDir, "MAA.exe"), Path.Combine(curDir, "MAA_win7.exe"), true); - string batFileContent = "@echo off\n" + - "ren MAA.exe MAA_v5.exe\n" + - "start \"\" .\\MAA_win7.exe"; - - // 将内容写入.bat文件 - File.WriteAllText("启动旧版.cmd", batFileContent); + File.Copy(System.Windows.Forms.Application.ExecutablePath, Path.Combine(curDir, "MAA_win7.exe"), true); + const string CmdFileContent = """ + @echo off + if exist MAA.exe ( + ren MAA.exe MAA_v5.exe + ) + start "" .\MAA_win7.exe + """; + File.WriteAllText("启动旧版.cmd", CmdFileContent); } string removeListFile = Path.Combine(extractDir, "removelist.txt"); @@ -306,11 +308,7 @@ namespace MaaWpfGui.ViewModels.UI ConfigurationHelper.Release(); // 重启进程(启动的是更新后的程序了) - var newProcess = new Process(); - newProcess.StartInfo.FileName = AppDomain.CurrentDomain.FriendlyName; - newProcess.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory(); - newProcess.Start(); - Application.Current.Shutdown(); + Bootstrapper.ShutdownAndRestartWithOutArgs(); return true;