prefsCleaner.bat: add -unattended flag

Usage:
  prefsCleaner.bat -unattended

Skips the prompt for user input and proceeds when -unattended is specified. If omitted, default behaviour is unchanged.

Code taken from updater.bat for consistency.

Please review this PR closely as I'm not fluent in batch scripting. The revised script appears to function properly with and without -unattended, but I'm not aware of common pitfalls.

Signed-off-by: Keith Harrison <keithh@protonmail.com>
This commit is contained in:
Keith Harrison 2023-01-17 13:25:32 -05:00
parent 62a68f0814
commit 4d67974120

View file

@ -7,6 +7,8 @@ REM ## version: 2.5
CD /D "%~dp0" CD /D "%~dp0"
GOTO parse
:begin :begin
ECHO: ECHO:
ECHO: ECHO:
@ -22,10 +24,12 @@ CALL :message "This will allow inactive preferences to be reset to their default
ECHO This Firefox profile shouldn't be in use during the process. ECHO This Firefox profile shouldn't be in use during the process.
CALL :message "" CALL :message ""
TIMEOUT 1 /nobreak >nul TIMEOUT 1 /nobreak >nul
CHOICE /C SHE /N /M "Start [S] Help [H] Exit [E]" IF NOT DEFINED _ua (
CLS CHOICE /C SHE /N /M "Start [S] Help [H] Exit [E]"
IF ERRORLEVEL 3 (EXIT /B) CLS
IF ERRORLEVEL 2 (GOTO :showhelp) IF ERRORLEVEL 3 (EXIT /B)
IF ERRORLEVEL 2 (GOTO :showhelp)
)
IF NOT EXIST "user.js" (CALL :abort "user.js not found in the current directory." 30) IF NOT EXIST "user.js" (CALL :abort "user.js not found in the current directory." 30)
IF NOT EXIST "prefs.js" (CALL :abort "prefs.js not found in the current directory." 30) IF NOT EXIST "prefs.js" (CALL :abort "prefs.js not found in the current directory." 30)
CALL :strlenCheck CALL :strlenCheck
@ -48,6 +52,14 @@ REM ########## Abort Function ###########
CALL :message %1 CALL :message %1
TIMEOUT %~2 >nul TIMEOUT %~2 >nul
EXIT EXIT
REM ########## Parse Function ###########
:parse
IF "%~1"=="" (GOTO endparse)
IF /I "%~1"=="-unattended" (SET _ua=1)
:endparse
GOTO begin
REM ########## Message Function ######### REM ########## Message Function #########
:message :message
ECHO: ECHO: