improve updater logic

This commit is contained in:
pointfeev 2023-06-03 18:16:55 -04:00
parent 8e98442924
commit 3522488392

View file

@ -191,9 +191,9 @@ internal sealed partial class UpdateForm : CustomForm
PackagePath.DeleteFile(canContinue); PackagePath.DeleteFile(canContinue);
if (canContinue) if (canContinue)
{ {
string currentPath = Program.CurrentProcessFilePath; string path = Program.CurrentProcessFilePath;
string currentDirectory = Path.GetDirectoryName(currentPath); string directory = Path.GetDirectoryName(path);
string currentExecutable = Path.GetFileName(currentPath); string file = Path.GetFileName(path);
StringBuilder commands = new(); StringBuilder commands = new();
_ = commands.AppendLine(CultureInfo.InvariantCulture, $"\nTASKKILL /F /T /PID {Program.CurrentProcessId}"); _ = commands.AppendLine(CultureInfo.InvariantCulture, $"\nTASKKILL /F /T /PID {Program.CurrentProcessId}");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $":LOOP"); _ = commands.AppendLine(CultureInfo.InvariantCulture, $":LOOP");
@ -202,8 +202,8 @@ internal sealed partial class UpdateForm : CustomForm
_ = commands.AppendLine(CultureInfo.InvariantCulture, $" TIMEOUT /T 1"); _ = commands.AppendLine(CultureInfo.InvariantCulture, $" TIMEOUT /T 1");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $" GOTO LOOP"); _ = commands.AppendLine(CultureInfo.InvariantCulture, $" GOTO LOOP");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $")"); _ = commands.AppendLine(CultureInfo.InvariantCulture, $")");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $"MOVE /Y \"{ExecutablePath}\" \"{currentExecutable}\""); _ = commands.AppendLine(CultureInfo.InvariantCulture, $"MOVE /Y \"{ExecutablePath}\" \"{path}\"");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $"START \"\" /D \"{currentDirectory}\" \"{currentExecutable}\""); _ = commands.AppendLine(CultureInfo.InvariantCulture, $"START \"\" /D \"{directory}\" \"{file}\"");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $"EXIT"); _ = commands.AppendLine(CultureInfo.InvariantCulture, $"EXIT");
UpdaterPath.WriteFile(commands.ToString(), true, this); UpdaterPath.WriteFile(commands.ToString(), true, this);
Process process = new(); Process process = new();