ktekinay / Kaju

Xojo code for implementing self-updating apps
MIT License
61 stars 33 forks source link

Change to the windows updater script to successfully complete and sta… #21

Open MisterBruno opened 2 years ago

MisterBruno commented 2 years ago

On Windows, if the version number contains parenthesis ie "1.0 (3) _32 bits", the updater script fails when trying to start the updated app. This happens in the last If block:

IF %PROCEED% == 1 (
     ECHO "... new app" >> "%LOGGER%" 2>&1
     START "" "%APP_PARENT%\%NEW_APP_NAME%" --kaju-success %APP_VERSION%
     GOTO :remove_backup_folder
) ELSE ...

The %APP_VERSION% variable is expanded before the code block is executed and the parenthesis make the entire block fail.

Adding setlocal enabledelayedexpansion and refering to the variable with!APP_VERSION! enables the variable to be expanded only when the specific line is executed, and not then the block code is evaluated, thus solving the problem.