From 8a45148cd12244a801e6ed04c8bc1c279937d4f8 Mon Sep 17 00:00:00 2001 From: claustromaniac <20734810+claustromaniac@users.noreply.github.com> Date: Sat, 11 Aug 2018 22:34:54 -0300 Subject: [PATCH] improve -updatebatch option --- updater.bat | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/updater.bat b/updater.bat index ad23efc..1c5beb7 100644 --- a/updater.bat +++ b/updater.bat @@ -31,10 +31,13 @@ IF DEFINED _updateb ( REM ## Phase 3 ##: The new script, with the original name, will: REM * Delete the [updated]*.bat script REM * Begin the normal routine + FC "[updated]!_myname!.bat" "!_myname!.bat" >nul + IF ERRORLEVEL 1 ( + CALL :message "Script updated^!" + TIMEOUT 3 >nul + ) REN "[updated]!_myname!.bat" "[updated]!_myname!.bat.old" DEL /F "[updated]!_myname!.bat.old" - CALL :message "Script updated^!" - TIMEOUT 3 >nul GOTO begin ) REM ## Phase 1 ## @@ -42,8 +45,8 @@ IF DEFINED _updateb ( REM * Start that script in a new CMD window REM * Exit CALL :message "Updating script..." - REM Uncomment the next line and comment the PowerShell call for testing. - REM COPY /B /Y "!_myname!.bat" "[updated]!_myname!.bat" + REM Uncomment the next line and comment out the PowerShell call for testing. + REM COPY /B /Y "!_myname!.bat" "[updated]!_myname!.bat" >nul ( PowerShell -Command "(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.bat', '[updated]!_myname!.bat')" ) >nul 2>&1