From 4d6797412019cdc84f6fae0496581c1e38fed0e2 Mon Sep 17 00:00:00 2001 From: Keith Harrison Date: Tue, 17 Jan 2023 13:25:32 -0500 Subject: [PATCH] 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 --- prefsCleaner.bat | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/prefsCleaner.bat b/prefsCleaner.bat index 7591c0e..eac7dc4 100644 --- a/prefsCleaner.bat +++ b/prefsCleaner.bat @@ -7,6 +7,8 @@ REM ## version: 2.5 CD /D "%~dp0" +GOTO parse + :begin 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. CALL :message "" TIMEOUT 1 /nobreak >nul -CHOICE /C SHE /N /M "Start [S] Help [H] Exit [E]" -CLS -IF ERRORLEVEL 3 (EXIT /B) -IF ERRORLEVEL 2 (GOTO :showhelp) +IF NOT DEFINED _ua ( + CHOICE /C SHE /N /M "Start [S] Help [H] Exit [E]" + CLS + 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 "prefs.js" (CALL :abort "prefs.js not found in the current directory." 30) CALL :strlenCheck @@ -48,6 +52,14 @@ REM ########## Abort Function ########### CALL :message %1 TIMEOUT %~2 >nul EXIT + +REM ########## Parse Function ########### +:parse +IF "%~1"=="" (GOTO endparse) +IF /I "%~1"=="-unattended" (SET _ua=1) +:endparse +GOTO begin + REM ########## Message Function ######### :message ECHO: