From 8f0bf1074eb6884593ad39a7bea0b2b8a9923302 Mon Sep 17 00:00:00 2001 From: Rohan Barar Date: Mon, 25 Aug 2025 09:37:13 +1000 Subject: [PATCH] Automatically enable Remote Desktop --- oem/RDPApps.reg | 12 ++++++++++++ oem/install.bat | 47 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/oem/RDPApps.reg b/oem/RDPApps.reg index f9e4b79..2de1b21 100644 --- a/oem/RDPApps.reg +++ b/oem/RDPApps.reg @@ -1,5 +1,17 @@ Windows Registry Editor Version 5.00 + ; Enable Remote Desktop + ; NOTE: The relevant firewall rule must be added separately with either: + ; Enable-NetFirewallRule -DisplayGroup "Remote Desktop" + ; or + ; netsh advfirewall firewall set rule group="remote desktop" new enable=Yes + [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server] + "fDenyTSConnections"=dword:00000000 + + ; Require Network Level Authentication (NLA) for Remote Desktop + [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp] + "UserAuthentication"=dword:00000001 + ; Disable RemoteApp allowlist so all applications can be used in Remote Desktop sessions [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\TSAppAllowList] "fDisabledAllowList"=dword:00000001 diff --git a/oem/install.bat b/oem/install.bat index 92bcc38..c13af96 100644 --- a/oem/install.bat +++ b/oem/install.bat @@ -1,14 +1,14 @@ @echo off title WinApps Setup Wizard -REM Check for administrative privileges +:: 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 + exit /b ) -REM Confirm the user wants to proceed with setup +:: Confirm the user wants to proceed with setup echo ============================================ echo WinApps Setup Wizard echo ============================================ @@ -18,16 +18,37 @@ pause >nul echo. echo [INFO] Starting setup... -REM Apply RDP and system configuration tweaks +:: Apply RDP and system configuration tweaks echo [INFO] Importing "RDPApps.reg"... -reg import "%~dp0RDPApps.reg" >nul 2>&1 -if %ERRORLEVEL% equ 0 ( - echo [SUCCESS] Imported "RDPApps.reg". +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] Failed to import "RDPApps.reg". + echo [ERROR] "RDPApps.reg" not found. Skipping... ) -REM Configure the system clock to use UTC instead of local time +:: 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 +if %ERRORLEVEL% equ 0 ( + echo [SUCCESS] Firewall changes applied successfully. +) else ( + :: 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. + echo Please manually enable Remote Desktop via 'Settings ► System ► Remote Desktop'. + ) +) + +:: 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 @@ -40,15 +61,15 @@ if exist "%~dp0Container.reg" ( echo [WARNING] "Container.reg" not found. Skipping... ) -REM Create a startup task to clean up stale network profiles +:: 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 +:: 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 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%". @@ -63,4 +84,4 @@ if %ERRORLEVEL% neq 0 ( echo. echo Press any key to exit... -pause >nul +pause >nul \ No newline at end of file