Test and update scripts on mini pc
This commit is contained in:
+118
-21
@@ -2,9 +2,17 @@
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
:: ============================================================================
|
||||
:: CONFIGURATION
|
||||
:: CONFIGURATION (SYNCED WITH INSTALL.BAT)
|
||||
:: ============================================================================
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
for %%I in ("%SCRIPT_DIR%..") do (
|
||||
set "ROOT_DIR=%%~fI\"
|
||||
set "ROOT_FOLDER_NAME=%%~nxI"
|
||||
)
|
||||
set "CLEAN_ROOT=%ROOT_DIR:~0,-1%"
|
||||
|
||||
set "WSL_DISTRO=Ubuntu-22.04"
|
||||
set "PROJECT_NAME=walmart"
|
||||
set "PROJECT_DIR=/opt/walmart"
|
||||
set "KIOSK_APP_DIR=C:\KioskApp"
|
||||
set "KIOSK_DATA_DIR=C:\KioskBrowserData"
|
||||
@@ -23,19 +31,41 @@ echo ===========================================================================
|
||||
echo DTS TORQUE VAULT - KIOSK MODE UNINSTALLER AND SYSTEM RESTORE
|
||||
echo ============================================================================
|
||||
echo.
|
||||
echo This tool will:
|
||||
echo 1. Disable Windows Auto-Logon and Kiosk Shell restrictions
|
||||
echo 2. Remove or restore the dedicated Kiosk user account
|
||||
echo 3. Remove startup tasks and restore default Power / Update policies
|
||||
echo 4. Optionally stop and remove Walmart Docker containers
|
||||
echo Select uninstall mode:
|
||||
echo [1] Auto Wipe All - Automatically remove Kiosk user, browser data,
|
||||
echo scheduled tasks, Docker containers, database volumes
|
||||
echo and the '%ROOT_FOLDER_NAME%' setup folder
|
||||
echo [2] Manual / Custom - Choose step-by-step what to keep or delete
|
||||
echo [0] Cancel
|
||||
echo.
|
||||
set /p CONFIRM="Are you sure you want to uninstall Kiosk Mode? (Y/N): "
|
||||
if /i not "%CONFIRM%"=="Y" (
|
||||
set "UNINSTALL_MODE="
|
||||
set /p UNINSTALL_MODE="Enter your choice [1 / 2 / 0]: "
|
||||
|
||||
if "%UNINSTALL_MODE%"=="0" (
|
||||
echo Uninstall cancelled.
|
||||
pause
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
set "AUTO_WIPE=0"
|
||||
if "%UNINSTALL_MODE%"=="1" (
|
||||
set "AUTO_WIPE=1"
|
||||
echo.
|
||||
echo [WARNING] Option 1 selected: ALL Kiosk settings, user profiles, browser data,
|
||||
echo and local database volumes will be permanently wiped!
|
||||
set "CONFIRM_WIPE="
|
||||
set /p CONFIRM_WIPE="Type YES to confirm full automatic wipe: "
|
||||
if /i not "!CONFIRM_WIPE!"=="YES" (
|
||||
echo Uninstall cancelled.
|
||||
pause
|
||||
exit /b 0
|
||||
)
|
||||
) else if not "%UNINSTALL_MODE%"=="2" (
|
||||
echo [ERROR] Invalid selection. Exiting.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: ============================================================================
|
||||
:: 1. DETECT CURRENT KIOSK ACCOUNT & DISABLE AUTO-LOGON
|
||||
:: ============================================================================
|
||||
@@ -71,13 +101,44 @@ echo Detected Kiosk account: "%KIOSK_USER%"
|
||||
for /f "tokens=3" %%S in ('query user "%KIOSK_USER%" 2^>nul ^| findstr /i "%KIOSK_USER%"') do logoff %%S >nul 2>&1
|
||||
timeout /t 2 /nobreak >nul
|
||||
|
||||
set /p DEL_USER="Delete Kiosk user account '%KIOSK_USER%' and its profile? (Y=Delete / N=Restore Desktop): "
|
||||
set "DEL_USER=Y"
|
||||
if "%AUTO_WIPE%"=="0" (
|
||||
set /p DEL_USER="Delete Kiosk user account '%KIOSK_USER%' and its profile? (Y=Delete / N=Restore Desktop): "
|
||||
)
|
||||
|
||||
if /i "%DEL_USER%"=="Y" (
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "$u='%KIOSK_USER%'; $acc=Get-LocalUser -Name $u -ErrorAction SilentlyContinue; if ($acc) { $sid=$acc.SID.Value; Get-CimInstance Win32_UserProfile -Filter \"SID='$sid'\" -ErrorAction SilentlyContinue | Remove-CimInstance -ErrorAction SilentlyContinue; Remove-LocalUser -Name $u -ErrorAction SilentlyContinue }"
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
|
||||
"$u='%KIOSK_USER%';" ^
|
||||
"$acc=Get-LocalUser -Name $u -ErrorAction SilentlyContinue;" ^
|
||||
"if ($acc) {" ^
|
||||
" $sid=$acc.SID.Value;" ^
|
||||
" Get-CimInstance Win32_UserProfile -Filter \"SID='$sid'\" -ErrorAction SilentlyContinue | Remove-CimInstance -ErrorAction SilentlyContinue;" ^
|
||||
" Remove-LocalUser -Name $u -ErrorAction SilentlyContinue" ^
|
||||
"}"
|
||||
echo - Removed Kiosk user "%KIOSK_USER%" and its local profile.
|
||||
) else (
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "$u='%KIOSK_USER%'; $acc=Get-LocalUser -Name $u -ErrorAction SilentlyContinue; if ($acc) { $sid=$acc.SID.Value; $p=(Get-ItemProperty \"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid\" -ErrorAction SilentlyContinue).ProfileImagePath; if ($p -and (Test-Path \"$p\NTUSER.DAT\")) { $loaded=$false; if (-not (Test-Path \"Registry::HKEY_USERS\$sid\")) { reg.exe load \"HKU\$sid\" \"$p\NTUSER.DAT\" >$null 2>&1; if ($LASTEXITCODE -eq 0) { $loaded=$true } } if (Test-Path \"Registry::HKEY_USERS\$sid\") { reg.exe delete \"HKU\$sid\Software\Microsoft\Windows\CurrentVersion\Policies\System\" /v Shell /f >$null 2>&1; reg.exe delete \"HKU\$sid\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\" /v Shell /f >$null 2>&1 } if ($loaded) { [gc]::Collect(); Start-Sleep 1; reg.exe unload \"HKU\$sid\" >$null 2>&1 } } }"
|
||||
echo - Restored normal Windows Desktop shell for "%KIOSK_USER%".
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
|
||||
"$u='%KIOSK_USER%';" ^
|
||||
"$acc=Get-LocalUser -Name $u -ErrorAction SilentlyContinue;" ^
|
||||
"if ($acc) {" ^
|
||||
" $sid=$acc.SID.Value;" ^
|
||||
" $p=(Get-ItemProperty \"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid\" -ErrorAction SilentlyContinue).ProfileImagePath;" ^
|
||||
" if ($p -and (Test-Path \"$p\NTUSER.DAT\")) {" ^
|
||||
" $loaded=$false;" ^
|
||||
" if (-not (Test-Path \"Registry::HKEY_USERS\$sid\")) {" ^
|
||||
" reg.exe load \"HKU\$sid\" \"$p\NTUSER.DAT\" >$null 2>&1;" ^
|
||||
" if ($LASTEXITCODE -eq 0) { $loaded=$true }" ^
|
||||
" }" ^
|
||||
" if (Test-Path \"Registry::HKEY_USERS\$sid\") {" ^
|
||||
" reg.exe delete \"HKU\$sid\Software\Microsoft\Windows\CurrentVersion\Policies\System\" /v Shell /f >$null 2>&1;" ^
|
||||
" reg.exe delete \"HKU\$sid\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\" /v Shell /f >$null 2>&1;" ^
|
||||
" $stuckPath=\"Registry::HKEY_USERS\$sid\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3\";" ^
|
||||
" if (Test-Path $stuckPath) { $v=(Get-ItemProperty -Path $stuckPath -Name Settings).Settings; $v[8]=2; Set-ItemProperty -Path $stuckPath -Name Settings -Value $v }" ^
|
||||
" }" ^
|
||||
" if ($loaded) { [gc]::Collect(); Start-Sleep 1; reg.exe unload \"HKU\$sid\" >$null 2>&1 }" ^
|
||||
" }" ^
|
||||
"}"
|
||||
echo - Restored normal Windows Desktop shell and taskbar for "%KIOSK_USER%".
|
||||
)
|
||||
goto :AFTER_KIOSK_USER
|
||||
|
||||
@@ -96,10 +157,15 @@ reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v "DTS_Mast
|
||||
if exist "%KIOSK_APP_DIR%" rmdir /s /q "%KIOSK_APP_DIR%" >nul 2>&1
|
||||
|
||||
if exist "%KIOSK_DATA_DIR%" (
|
||||
set /p DEL_BROWSER="Delete persistent Kiosk browser data at %KIOSK_DATA_DIR%? (Y/N): "
|
||||
set "DEL_BROWSER=Y"
|
||||
if "%AUTO_WIPE%"=="0" (
|
||||
set /p DEL_BROWSER="Delete persistent Kiosk browser data at %KIOSK_DATA_DIR%? (Y/N): "
|
||||
)
|
||||
if /i "!DEL_BROWSER!"=="Y" (
|
||||
rmdir /s /q "%KIOSK_DATA_DIR%" >nul 2>&1
|
||||
echo - Removed %KIOSK_DATA_DIR%
|
||||
) else (
|
||||
echo - Preserved %KIOSK_DATA_DIR%
|
||||
)
|
||||
)
|
||||
|
||||
@@ -111,28 +177,46 @@ powercfg -setactive 381b4222-f694-41f0-9685-ff5bb260df2e >nul 2>&1
|
||||
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoRebootWithLoggedOnUsers" /f >nul 2>&1
|
||||
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "AUOptions" /f >nul 2>&1
|
||||
|
||||
if "%AUTO_WIPE%"=="1" if exist "%USERPROFILE%\.wslconfig" del /f /q "%USERPROFILE%\.wslconfig" >nul 2>&1 & echo - Removed custom .wslconfig.
|
||||
|
||||
:: ============================================================================
|
||||
:: 5. OPTIONAL: STOP AND REMOVE WALMART DOCKER CONTAINERS
|
||||
:: 5. STOP AND REMOVE WALMART DOCKER CONTAINERS
|
||||
:: ============================================================================
|
||||
echo [5/5] Checking WSL Docker containers...
|
||||
wsl -d %WSL_DISTRO% -u root true >nul 2>&1
|
||||
if %errorLevel% neq 0 goto :UNINSTALL_DONE
|
||||
|
||||
set "STOP_DOCKER="
|
||||
set /p STOP_DOCKER="Stop and remove Walmart Docker containers in %PROJECT_DIR%? (Y/N): "
|
||||
set "STOP_DOCKER=Y"
|
||||
if "%AUTO_WIPE%"=="0" (
|
||||
set /p STOP_DOCKER="Stop and remove Walmart Docker containers in %PROJECT_DIR%? (Y/N): "
|
||||
)
|
||||
if /i not "%STOP_DOCKER%"=="Y" goto :UNINSTALL_DONE
|
||||
|
||||
set "DEL_VOLUMES="
|
||||
set /p DEL_VOLUMES="Also delete database volumes - WARNING deletes all local data? (Y/N): "
|
||||
set "DEL_VOLUMES=Y"
|
||||
if "%AUTO_WIPE%"=="0" (
|
||||
set /p DEL_VOLUMES="Also delete database volumes - WARNING deletes all local data? (Y/N): "
|
||||
)
|
||||
|
||||
if /i "%DEL_VOLUMES%"=="Y" (
|
||||
wsl -d %WSL_DISTRO% -u root bash -c "cd %PROJECT_DIR% 2>/dev/null && docker compose down -v && rm -rf %PROJECT_DIR%"
|
||||
echo - Removed containers, volumes, and %PROJECT_DIR%.
|
||||
wsl -d %WSL_DISTRO% -u root bash -c "cd '%PROJECT_DIR%' 2>/dev/null && docker compose -p '%PROJECT_NAME%' down -v --remove-orphans; rm -rf '%PROJECT_DIR%'"
|
||||
echo - Removed containers, database volumes, and %PROJECT_DIR%.
|
||||
) else (
|
||||
wsl -d %WSL_DISTRO% -u root bash -c "cd %PROJECT_DIR% 2>/dev/null && docker compose down"
|
||||
wsl -d %WSL_DISTRO% -u root bash -c "cd '%PROJECT_DIR%' 2>/dev/null && docker compose -p '%PROJECT_NAME%' down --remove-orphans"
|
||||
echo - Stopped and removed containers - database volumes preserved.
|
||||
)
|
||||
|
||||
:UNINSTALL_DONE
|
||||
set "DEL_SETUP_DIR=N"
|
||||
if /i "%ROOT_FOLDER_NAME%"=="mini-pc-setup" (
|
||||
if "%AUTO_WIPE%"=="1" (
|
||||
set "DEL_SETUP_DIR=Y"
|
||||
) else (
|
||||
set /p DEL_SETUP_DIR="Delete setup folder '%CLEAN_ROOT%' only? (Y/N): "
|
||||
)
|
||||
) else (
|
||||
echo [INFO] Skipping setup folder deletion because parent folder is '%ROOT_FOLDER_NAME%' - not 'mini-pc-setup'.
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ============================================================================
|
||||
echo UNINSTALL COMPLETED!
|
||||
@@ -140,7 +224,20 @@ echo - Windows Auto-Logon and Kiosk restrictions have been removed
|
||||
echo - Normal Windows Desktop and Power/Update policies restored
|
||||
echo ============================================================================
|
||||
echo.
|
||||
|
||||
set "REBOOT_NOW="
|
||||
set /p REBOOT_NOW="Reboot now to apply all changes cleanly? (Y/N): "
|
||||
|
||||
if /i "%DEL_SETUP_DIR%"=="Y" (
|
||||
echo Cleaning up '%CLEAN_ROOT%' in 2 seconds - other folders in parent directory remain untouched...
|
||||
cd /d "%TEMP%"
|
||||
if /i "%REBOOT_NOW%"=="Y" (
|
||||
start "" /b cmd /c "timeout /t 2 /nobreak >nul & rmdir /s /q "%CLEAN_ROOT%" & shutdown /r /t 2"
|
||||
) else (
|
||||
start "" /b cmd /c "timeout /t 2 /nobreak >nul & rmdir /s /q "%CLEAN_ROOT%""
|
||||
)
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
if /i "%REBOOT_NOW%"=="Y" shutdown /r /t 3
|
||||
pause
|
||||
Reference in New Issue
Block a user