From e8037948f46ff5f343204e9cee549ba1fb9a935d Mon Sep 17 00:00:00 2001 From: Rohan Barar Date: Fri, 1 Aug 2025 18:48:16 +1000 Subject: [PATCH] various improvements to install.bat --- oem/install.bat | 75 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/oem/install.bat b/oem/install.bat index b387507..504cace 100644 --- a/oem/install.bat +++ b/oem/install.bat @@ -1,25 +1,66 @@ @echo off +title WinApps Setup Wizard -reg import %~dp0\RDPApps.reg - -if exist %~dp0\Container.reg ( - reg import %~dp0\Container.reg +REM Check for administrative privileges +fltmc >nul 2>&1 || ( + echo [INFO] Script not running as administrator. Attempting to relaunch with elevation... + powershell -Command "Start-Process '%~f0' -Verb runAs" + exit /b 0 ) -REM Create network profile cleanup scheduled task -copy %~dp0\NetProfileCleanup.ps1 %windir% -set "taskname=NetworkProfileCleanup" -set "command=powershell.exe -ExecutionPolicy Bypass -File "%windir%\NetProfileCleanup.ps1^"" +REM Confirm the user wants to proceed with setup +echo ============================================ +echo WinApps Setup Wizard +echo ============================================ +echo. +echo Press any key to continue or close this window to cancel... +pause >nul +echo. +echo [INFO] Starting setup... -schtasks /query /tn "%taskname%" >nul 2>&1 +REM Apply RDP and system configuration tweaks +echo [INFO] Importing "RDPApps.reg"... +reg import "%~dp0RDPApps.reg" >nul 2>&1 if %ERRORLEVEL% equ 0 ( - echo Task "%taskname%" already exists, deleting it first... - schtasks /delete /tn "%taskname%" /f -) - -schtasks /create /tn "%taskname%" /tr "%command%" /sc onstart /ru "SYSTEM" /rl HIGHEST /f -if %ERRORLEVEL% equ 0 ( - echo Scheduled task "%taskname%" created successfully. + echo [SUCCESS] Imported "RDPApps.reg". ) else ( - echo Failed to create scheduled task. + echo [ERROR] Failed to import "RDPApps.reg". ) + +REM Configure the system clock to use UTC instead of local time +if exist "%~dp0Container.reg" ( + echo [INFO] Importing "Container.reg"... + reg import "%~dp0Container.reg" >nul 2>&1 + if %ERRORLEVEL% equ 0 ( + echo [SUCCESS] Imported "Container.reg". + ) else ( + echo [ERROR] Failed to import "Container.reg". + ) +) else ( + echo [WARNING] "Container.reg" not found. Skipping... +) + +REM Create a startup task to clean up stale network profiles +echo [INFO] Creating network profile cleanup task... + +REM Initialise values required to create the startup task +set "scriptpath=%windir%\NetProfileCleanup.ps1" +set "taskname=WinApps_NetworkProfileCleanup" +set "command=powershell.exe -ExecutionPolicy Bypass -File ""%scriptpath%""" + +REM Copy the script to the Windows directory +copy /Y "%~dp0NetProfileCleanup.ps1" "%scriptpath%" >nul +if %ERRORLEVEL% neq 0 ( + echo [ERROR] Failed to copy "NetProfileCleanup.ps1" to "%windir%". +) else ( + schtasks /create /tn "%taskname%" /tr "%command%" /sc onstart /ru "SYSTEM" /rl HIGHEST /f >nul 2>&1 + if %ERRORLEVEL% equ 0 ( + echo [SUCCESS] Created scheduled task "%taskname%". + ) else ( + echo [ERROR] Failed to create scheduled task "%taskname%". + ) +) + +echo. +echo Press any key to exit... +pause >nul \ No newline at end of file