|
1 | 1 | @echo off |
| 2 | +title WinApps Setup Wizard |
2 | 3 |
|
3 | | -reg import %~dp0\RDPApps.reg |
4 | | - |
5 | | -if exists %~dp0\Container.reg ( |
6 | | - reg import %~dp0\Container.reg |
| 4 | +REM Check for administrative privileges |
| 5 | +fltmc >nul 2>&1 || ( |
| 6 | + echo [INFO] Script not running as administrator. Attempting to relaunch with elevation... |
| 7 | + powershell -Command "Start-Process '%~f0' -Verb runAs" |
| 8 | + exit /b 0 |
7 | 9 | ) |
8 | 10 |
|
9 | | -REM Create network profile cleanup scheduled task |
10 | | -copy %~dp0\NetProfileCleanup.ps1 %windir% |
11 | | -set "taskname=NetworkProfileCleanup" |
12 | | -set "command=powershell.exe -ExecutionPolicy Bypass -File "%windir%\NetProfileCleanup.ps1^"" |
| 11 | +REM Confirm the user wants to proceed with setup |
| 12 | +echo ============================================ |
| 13 | +echo WinApps Setup Wizard |
| 14 | +echo ============================================ |
| 15 | +echo. |
| 16 | +echo Press any key to continue or close this window to cancel... |
| 17 | +pause >nul |
| 18 | +echo. |
| 19 | +echo [INFO] Starting setup... |
13 | 20 |
|
14 | | -schtasks /query /tn "%taskname%" >nul 2>&1 |
| 21 | +REM Apply RDP and system configuration tweaks |
| 22 | +echo [INFO] Importing "RDPApps.reg"... |
| 23 | +reg import "%~dp0RDPApps.reg" >nul 2>&1 |
15 | 24 | if %ERRORLEVEL% equ 0 ( |
16 | | - echo Task "%taskname%" already exists, deleting it first... |
17 | | - schtasks /delete /tn "%taskname%" /f |
| 25 | + echo [SUCCESS] Imported "RDPApps.reg". |
| 26 | +) else ( |
| 27 | + echo [ERROR] Failed to import "RDPApps.reg". |
18 | 28 | ) |
19 | 29 |
|
20 | | -schtasks /create /tn "%taskname%" /tr "%command%" /sc onstart /ru "SYSTEM" /rl HIGHEST /f |
21 | | -if %ERRORLEVEL% equ 0 ( |
22 | | - echo Scheduled task "%taskname%" created successfully. |
| 30 | +REM Configure the system clock to use UTC instead of local time |
| 31 | +if exist "%~dp0Container.reg" ( |
| 32 | + echo [INFO] Importing "Container.reg"... |
| 33 | + reg import "%~dp0Container.reg" >nul 2>&1 |
| 34 | + if %ERRORLEVEL% equ 0 ( |
| 35 | + echo [SUCCESS] Imported "Container.reg". |
| 36 | + ) else ( |
| 37 | + echo [ERROR] Failed to import "Container.reg". |
| 38 | + ) |
23 | 39 | ) else ( |
24 | | - echo Failed to create scheduled task. |
| 40 | + echo [WARNING] "Container.reg" not found. Skipping... |
25 | 41 | ) |
| 42 | + |
| 43 | +REM Create a startup task to clean up stale network profiles |
| 44 | +echo [INFO] Creating network profile cleanup task... |
| 45 | + |
| 46 | +REM Initialise values required to create the startup task |
| 47 | +set "scriptpath=%windir%\NetProfileCleanup.ps1" |
| 48 | +set "taskname=WinApps_NetworkProfileCleanup" |
| 49 | +set "command=powershell.exe -ExecutionPolicy Bypass -File ""%scriptpath%""" |
| 50 | + |
| 51 | +REM Copy the script to the Windows directory |
| 52 | +copy /Y "%~dp0NetProfileCleanup.ps1" "%scriptpath%" >nul |
| 53 | +if %ERRORLEVEL% neq 0 ( |
| 54 | + echo [ERROR] Failed to copy "NetProfileCleanup.ps1" to "%windir%". |
| 55 | +) else ( |
| 56 | + schtasks /create /tn "%taskname%" /tr "%command%" /sc onstart /ru "SYSTEM" /rl HIGHEST /f >nul 2>&1 |
| 57 | + if %ERRORLEVEL% equ 0 ( |
| 58 | + echo [SUCCESS] Created scheduled task "%taskname%". |
| 59 | + ) else ( |
| 60 | + echo [ERROR] Failed to create scheduled task "%taskname%". |
| 61 | + ) |
| 62 | +) |
| 63 | + |
| 64 | +echo. |
| 65 | +echo Press any key to exit... |
| 66 | +pause >nul |
0 commit comments