Files
winapps/oem/install.bat
T

97 lines
3.5 KiB
Batchfile
Raw Normal View History

2024-05-26 12:31:31 +02:00
@echo off
2025-08-01 18:48:16 +10:00
title WinApps Setup Wizard
2024-05-26 12:31:31 +02:00
2025-08-25 09:37:13 +10:00
:: Check for administrative privileges
2025-08-01 18:48:16 +10:00
fltmc >nul 2>&1 || (
echo [INFO] Script not running as administrator. Attempting to relaunch with elevation...
powershell -Command "Start-Process '%~f0' -Verb runAs"
2025-08-25 09:37:13 +10:00
exit /b
2024-12-13 20:06:30 +01:00
)
2024-09-18 14:50:48 +10:00
2025-08-01 18:48:16 +10:00
echo ============================================
echo WinApps Setup Wizard
echo ============================================
echo.
echo [INFO] Starting setup...
2024-09-18 14:50:48 +10:00
2025-08-25 09:37:13 +10:00
:: Apply RDP and system configuration tweaks
2025-08-01 18:48:16 +10:00
echo [INFO] Importing "RDPApps.reg"...
2025-08-25 09:37:13 +10:00
if exist "%~dp0RDPApps.reg" (
reg import "%~dp0RDPApps.reg" >nul 2>&1
if %ERRORLEVEL% equ 0 (
echo [SUCCESS] Imported "RDPApps.reg".
) else (
echo [ERROR] Failed to import "RDPApps.reg".
)
) else (
echo [ERROR] "RDPApps.reg" not found. Skipping...
2024-09-18 14:50:48 +10:00
)
2025-08-25 09:37:13 +10:00
:: Allow Remote Desktop connections through the firewall
echo [INFO] Allowing Remote Desktop connections through the firewall...
powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass ^
-Command "if (Get-Command Enable-NetFirewallRule -ErrorAction SilentlyContinue) { try { Enable-NetFirewallRule -DisplayGroup 'Remote Desktop' -ErrorAction Stop; exit 0 } catch { exit 1 } } else { exit 2 }" >nul 2>&1
2024-09-18 14:50:48 +10:00
if %ERRORLEVEL% equ 0 (
2025-08-25 09:37:13 +10:00
echo [SUCCESS] Firewall changes applied successfully.
2024-09-18 14:50:48 +10:00
) else (
2025-08-25 09:37:13 +10:00
:: Fallback to using 'netsh' to make the firewall modification
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes >nul 2>&1
if %ERRORLEVEL% equ 0 (
echo [SUCCESS] Firewall changes applied successfully.
) else (
echo [ERROR] Failed to apply firewall changes.
2025-09-20 09:00:36 +10:00
echo Please manually enable Remote Desktop via 'Settings --> System --> Remote Desktop'.
2025-08-25 09:37:13 +10:00
)
2024-09-18 14:50:48 +10:00
)
2025-08-25 09:37:13 +10:00
:: Configure the system clock to use UTC instead of local time
2025-08-01 18:48:16 +10:00
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".
)
2024-09-18 14:50:48 +10:00
) else (
2025-08-01 18:48:16 +10:00
echo [WARNING] "Container.reg" not found. Skipping...
)
2025-08-01 18:48:16 +10:00
2025-08-25 09:37:13 +10:00
:: Create a startup task to clean up stale network profiles
2025-08-01 18:48:16 +10:00
echo [INFO] Creating network profile cleanup task...
2025-08-25 09:37:13 +10:00
:: Initialise values required to create the startup task
2025-08-01 18:48:16 +10:00
set "scriptpath=%windir%\NetProfileCleanup.ps1"
set "taskname=WinApps_NetworkProfileCleanup"
set "command=powershell.exe -ExecutionPolicy Bypass -File ""%scriptpath%"""
2025-08-25 09:37:13 +10:00
:: Copy the script to the Windows directory
2025-08-01 18:48:16 +10:00
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%".
)
)
2025-06-23 14:37:54 +01:00
REM Create time sync task to be run by the user at login
copy %~dp0\TimeSync.ps1 %windir%
set "taskname2=TimeSync"
set "command2=powershell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -File \"%windir%\TimeSync.ps1\""
schtasks /query /tn "%taskname2%" >nul
if %ERRORLEVEL% equ 0 (
echo %DATE% %TIME% Task "%taskname2%" already exists, skipping creation.
2025-06-23 14:37:54 +01:00
) else (
schtasks /create /tn "%taskname2%" /tr "%command2%" /sc onlogon /rl HIGHEST /f
2025-06-23 14:37:54 +01:00
if %ERRORLEVEL% equ 0 (
echo %DATE% %TIME% Scheduled task "%taskname2%" created successfully.
) else (
echo %DATE% %TIME% Failed to create scheduled task %taskname2%.
)
)