From 8d3816553be5e9c7e5a7d13157cc4c1ea5f1d05d Mon Sep 17 00:00:00 2001 From: Kang Yu Date: Wed, 28 Aug 2024 17:09:45 -0700 Subject: [PATCH] #348, do upgrade after pw process is killed --- .../SystrayShell/SystrayForm.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Ninjacrab.PersistentWindows.Solution/SystrayShell/SystrayForm.cs b/Ninjacrab.PersistentWindows.Solution/SystrayShell/SystrayForm.cs index 588ad79..c234102 100644 --- a/Ninjacrab.PersistentWindows.Solution/SystrayShell/SystrayForm.cs +++ b/Ninjacrab.PersistentWindows.Solution/SystrayShell/SystrayForm.cs @@ -266,7 +266,10 @@ namespace PersistentWindows.SystrayShell upgradeDownloaded[latestVersion] = true; string batFile = Path.Combine(Program.AppdataFolder, $"pw_upgrade.bat"); - string content = "timeout /t 10 /nobreak > NUL"; + string content = ":wait_to_finish"; + content += "\ntimeout /t 2 /nobreak >nul"; + content += "\ntasklist | find \"PersistentWindows\" >nul"; + content += "\nif not errorlevel 1 goto wait_to_finish"; content += $"\ncopy /Y \"{dst_dir}\\*.*\" \"{install_dir}\""; content += "\nstart \"\" /B \"" + Path.Combine(install_dir, Application.ProductName) + ".exe\" " + Program.CmdArgs; File.WriteAllText(batFile, content);