146 lines
7.7 KiB
Batchfile
146 lines
7.7 KiB
Batchfile
@echo off
|
|
setlocal EnableDelayedExpansion
|
|
|
|
:: ============================================================================
|
|
:: CONFIGURATION
|
|
:: ============================================================================
|
|
set "WSL_DISTRO=Ubuntu-22.04"
|
|
set "PROJECT_DIR=/opt/walmart"
|
|
set "KIOSK_APP_DIR=C:\KioskApp"
|
|
set "KIOSK_DATA_DIR=C:\KioskBrowserData"
|
|
|
|
:: ============================================================================
|
|
:: 0. AUTO-ELEVATE TO ADMINISTRATOR
|
|
:: ============================================================================
|
|
net session >nul 2>&1
|
|
if %errorLevel% neq 0 (
|
|
echo Requesting Administrator privileges...
|
|
powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
|
|
exit /b
|
|
)
|
|
|
|
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.
|
|
set /p CONFIRM="Are you sure you want to uninstall Kiosk Mode? (Y/N): "
|
|
if /i not "%CONFIRM%"=="Y" (
|
|
echo Uninstall cancelled.
|
|
pause
|
|
exit /b 0
|
|
)
|
|
|
|
:: ============================================================================
|
|
:: 1. DETECT CURRENT KIOSK ACCOUNT & DISABLE AUTO-LOGON
|
|
:: ============================================================================
|
|
echo.
|
|
echo [1/5] Disabling Windows Auto-Logon and Edge Kiosk policies...
|
|
|
|
set "KIOSK_USER="
|
|
for /f "tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultUserName" 2^>nul') do set "KIOSK_USER=%%B"
|
|
|
|
set "WINLOGON_KEY=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
|
|
reg add "%WINLOGON_KEY%" /v "AutoAdminLogon" /t REG_SZ /d "0" /f >nul 2>&1
|
|
reg delete "%WINLOGON_KEY%" /v "DefaultPassword" /f >nul 2>&1
|
|
reg delete "%WINLOGON_KEY%" /v "AutoLogonCount" /f >nul 2>&1
|
|
reg add "%WINLOGON_KEY%" /v "Shell" /t REG_SZ /d "explorer.exe" /f >nul 2>&1
|
|
reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "Shell" /f >nul 2>&1
|
|
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v "Shell" /f >nul 2>&1
|
|
|
|
set "EDGE_POL=HKLM\SOFTWARE\Policies\Microsoft\Edge"
|
|
reg delete "%EDGE_POL%" /v "InPrivateModeAvailability" /f >nul 2>&1
|
|
reg delete "%EDGE_POL%" /v "ClearBrowsingDataOnExit" /f >nul 2>&1
|
|
reg delete "%EDGE_POL%" /v "RestoreOnStartup" /f >nul 2>&1
|
|
|
|
:: ============================================================================
|
|
:: 2. REMOVE OR RESTORE DEDICATED KIOSK USER ACCOUNT
|
|
:: ============================================================================
|
|
echo [2/5] Handling dedicated Kiosk user account...
|
|
|
|
if "%KIOSK_USER%"=="" goto :NO_KIOSK_USER
|
|
if /i "%KIOSK_USER%"=="%USERNAME%" goto :NO_KIOSK_USER
|
|
if /i "%KIOSK_USER%"=="Administrator" goto :NO_KIOSK_USER
|
|
|
|
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): "
|
|
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 }"
|
|
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%".
|
|
)
|
|
goto :AFTER_KIOSK_USER
|
|
|
|
:NO_KIOSK_USER
|
|
echo - No separate Kiosk user account needed removal.
|
|
:AFTER_KIOSK_USER
|
|
|
|
:: ============================================================================
|
|
:: 3. REMOVE SCHEDULED TASKS AND KIOSK LOCAL FILES
|
|
:: ============================================================================
|
|
echo [3/5] Removing scheduled tasks and local Kiosk app files...
|
|
schtasks /delete /tn "DTS_WSL_Docker_AutoStart" /f >nul 2>&1
|
|
schtasks /delete /tn "DTS_Torque_Vault_Kiosk" /f >nul 2>&1
|
|
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v "DTS_Master_Setup" /f >nul 2>&1
|
|
|
|
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): "
|
|
if /i "!DEL_BROWSER!"=="Y" (
|
|
rmdir /s /q "%KIOSK_DATA_DIR%" >nul 2>&1
|
|
echo - Removed %KIOSK_DATA_DIR%
|
|
)
|
|
)
|
|
|
|
:: ============================================================================
|
|
:: 4. RESTORE DEFAULT WINDOWS POWER PLAN AND UPDATE POLICIES
|
|
:: ============================================================================
|
|
echo [4/5] Restoring default Balanced Power Plan and Windows Update settings...
|
|
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
|
|
|
|
:: ============================================================================
|
|
:: 5. OPTIONAL: 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): "
|
|
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): "
|
|
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%.
|
|
) else (
|
|
wsl -d %WSL_DISTRO% -u root bash -c "cd %PROJECT_DIR% 2>/dev/null && docker compose down"
|
|
echo - Stopped and removed containers - database volumes preserved.
|
|
)
|
|
|
|
:UNINSTALL_DONE
|
|
echo.
|
|
echo ============================================================================
|
|
echo UNINSTALL COMPLETED!
|
|
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 "%REBOOT_NOW%"=="Y" shutdown /r /t 3
|
|
pause |