improve updater logic

This commit is contained in:
pointfeev 2023-06-03 18:10:22 -04:00
parent 1b1f0bf494
commit 8e98442924
2 changed files with 4 additions and 7 deletions

View file

@ -4,7 +4,7 @@
<TargetFramework>net7.0-windows</TargetFramework>
<UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>Resources\ini.ico</ApplicationIcon>
<Version>4.9.3</Version>
<Version>4.9.4</Version>
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>
<Company>CreamInstaller</Company>
<Product>Automatic DLC Unlocker Installer &amp; Configuration Generator</Product>

View file

@ -193,8 +193,7 @@ internal sealed partial class UpdateForm : CustomForm
{
string currentPath = Program.CurrentProcessFilePath;
string currentDirectory = Path.GetDirectoryName(currentPath);
string properExecutable = Path.GetFileName(ExecutablePath);
string properExecutablePath = Path.Combine(currentDirectory!, properExecutable!);
string currentExecutable = Path.GetFileName(currentPath);
StringBuilder commands = new();
_ = commands.AppendLine(CultureInfo.InvariantCulture, $"\nTASKKILL /F /T /PID {Program.CurrentProcessId}");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $":LOOP");
@ -203,10 +202,8 @@ internal sealed partial class UpdateForm : CustomForm
_ = commands.AppendLine(CultureInfo.InvariantCulture, $" TIMEOUT /T 1");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $" GOTO LOOP");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $")");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $"DEL /F /Q \"{currentPath}\"");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $"DEL /F /Q \"{properExecutablePath}\"");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $"MOVE /Y \"{ExecutablePath}\" \"{properExecutablePath}\"");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $"START \"\" /D \"{currentDirectory}\" \"{properExecutable}\"");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $"MOVE /Y \"{ExecutablePath}\" \"{currentExecutable}\"");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $"START \"\" /D \"{currentDirectory}\" \"{currentExecutable}\"");
_ = commands.AppendLine(CultureInfo.InvariantCulture, $"EXIT");
UpdaterPath.WriteFile(commands.ToString(), true, this);
Process process = new();