@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
COLOR 0A
TITLE Shutdown Windows

REM GitHub: https://github.com/slyfox1186/script-repo/tree/main/Batch

SET SD="%windir%\System32\shutdown.exe"
SET SEC=6

:MENU
CLS
ECHO [1] RESTART (DEFAULT)
ECHO [2] RESTART AND RE-REGISTER APPS
ECHO [3] RESTART WITH ADVANCED BOOT OPTIONS
ECHO [4] RESTART INTO UEFI/BIOS MENU
ECHO [5] SHUTDOWN (DEFAULT)
ECHO [6] SHUTDOWN AND RE-REGISTER APPS
ECHO [7] LOG OFF CURRENT USER
ECHO [8] EXIT
ECHO=

CHOICE /C 12345678 /N

    IF ERRORLEVEL 8 GOTO :EOF
    IF ERRORLEVEL 7 SET "_ECHO=LOGGING OUT USER" & SET "FLAGS=/L" & GOTO EXECUTE
    IF ERRORLEVEL 6 SET "_ECHO=SHUTDOWN AND RE-REGISTER APPS" & SET "FLAGS=/SG /T" & GOTO EXECUTE
    IF ERRORLEVEL 5 SET "_ECHO=SHUTDOWN (DEFAULT)" & SET "FLAGS=/S /T" & GOTO EXECUTE
    IF ERRORLEVEL 4 SET "_ECHO=RESTART INTO UEFI/BIOS MENU" & SET "FLAGS=/R /FW /T" & GOTO EXECUTE
    IF ERRORLEVEL 3 SET "_ECHO=RESTART WITH ADVANCED BOOT OPTIONS" & SET "FLAGS=/R /O /T" & GOTO EXECUTE
    IF ERRORLEVEL 2 SET "_ECHO=RESTART AND RE-REGISTER APPS" & SET "FLAGS=/G /T" & GOTO EXECUTE
    IF ERRORLEVEL 1 SET "_ECHO=RESTART (DEFAULT)" & SET "FLAGS=/R /T" & GOTO EXECUTE

:EXECUTE
CLS
ECHO %_ECHO%
IF "%FLAGS%" EQU "/L" (%SD% %FLAGS%) ELSE (%SD% %FLAGS% %SEC%)

TASKLIST | FINDSTR "PickerHost.exe" >NUL || TIMEOUT 1 /NOBREAK >NUL
TASKKILL /F /IM "PickerHost.exe" /T >NUL 2>&1

ECHO=
PAUSE
GOTO MENU@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
COLOR 0A
TITLE Shutdown Windows

SET SD="%windir%\System32\shutdown.exe"
SET SEC=6

:MENU
CLS
ECHO [1] RESTART (DEFAULT)
ECHO [2] RESTART AND RE-REGISTER APPS
ECHO [3] RESTART WITH ADVANCED BOOT OPTIONS
ECHO [4] RESTART INTO UEFI/BIOS MENU
ECHO [5] SHUTDOWN (DEFAULT)
ECHO [6] SHUTDOWN AND RE-REGISTER APPS
ECHO [7] LOG OFF CURRENT USER
ECHO [8] EXIT
ECHO=

CHOICE /C 12345678 /N

    IF ERRORLEVEL 8 GOTO :EOF
    IF ERRORLEVEL 7 SET "_ECHO=LOGGING OUT USER" & SET "FLAGS=/L" & GOTO EXECUTE
    IF ERRORLEVEL 6 SET "_ECHO=SHUTDOWN AND RE-REGISTER APPS" & SET "FLAGS=/SG /T" & GOTO EXECUTE
    IF ERRORLEVEL 5 SET "_ECHO=SHUTDOWN (DEFAULT)" & SET "FLAGS=/S /T" & GOTO EXECUTE
    IF ERRORLEVEL 4 SET "_ECHO=RESTART INTO UEFI/BIOS MENU" & SET "FLAGS=/R /FW /T" & GOTO EXECUTE
    IF ERRORLEVEL 3 SET "_ECHO=RESTART WITH ADVANCED BOOT OPTIONS" & SET "FLAGS=/R /O /T" & GOTO EXECUTE
    IF ERRORLEVEL 2 SET "_ECHO=RESTART AND RE-REGISTER APPS" & SET "FLAGS=/G /T" & GOTO EXECUTE
    IF ERRORLEVEL 1 SET "_ECHO=RESTART (DEFAULT)" & SET "FLAGS=/R /T" & GOTO EXECUTE

:EXECUTE
CLS
ECHO %_ECHO%
IF "%FLAGS%" EQU "/L" (%SD% %FLAGS%) ELSE (%SD% %FLAGS% %SEC%)

TASKLIST | FINDSTR "PickerHost.exe" >NUL || TIMEOUT 1 /NOBREAK >NUL
TASKKILL /F /IM "PickerHost.exe" /T >NUL 2>&1

ECHO=
PAUSE
GOTO MENU
