From 601965418839176f339540bdac2005936d6282e5 Mon Sep 17 00:00:00 2001 From: sasheg dev <152582704+SashegDev@users.noreply.github.com> Date: Thu, 22 Oct 2026 16:55:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D1=83=D0=BD=D0=BD=D0=B5=D0=BB=D1=8C=20?= =?UTF-8?q?=D0=B8=20=D1=83=D0=B4=D0=B0=D0=BB=D1=91=D0=BD=D0=BD=D1=8B=D0=B9?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B1=D0=BE=D1=87=D0=B8=D0=B9=20=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D0=BB:=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D1=8B=20?= =?UTF-8?q?=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=BE=20=D0=BF=D1=80=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D1=8B=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B8?= =?UTF-8?q?=D0=B3=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/enable-rdp.ps1 | 57 +++++++++++++++++++++++++++ tools/{tunnel-game.ps1 => tunnel.ps1} | 33 ++++++++-------- 2 files changed, 74 insertions(+), 16 deletions(-) create mode 100644 tools/enable-rdp.ps1 rename tools/{tunnel-game.ps1 => tunnel.ps1} (70%) diff --git a/tools/enable-rdp.ps1 b/tools/enable-rdp.ps1 new file mode 100644 index 0000000..e738e56 --- /dev/null +++ b/tools/enable-rdp.ps1 @@ -0,0 +1,57 @@ +# Turns on the remote desktop on this machine. +# +# tools\enable-rdp.ps1 [-Disable] [-OpenFirewall] +# +# The remote desktop is reached through the tunnel, so the connection comes +# from the loopback and the port does not have to be open on the local +# network. The firewall rule is therefore only added when it is asked for. +# +# The user of the remote desktop has to have a password: a Windows account +# without one is not let in. +# +# ASCII only: PowerShell 5.1 reads a .ps1 without a byte order mark using the +# system ANSI code page. + +param( + [switch]$Disable, + [switch]$OpenFirewall +) + +$ErrorActionPreference = 'Stop' + +if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent() + ).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + throw 'run this from an elevated powershell' +} + +$key = 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' +$winlogon = 'HKLM:\SYSTEM\CurrentControlSet\Control\Winlogon' + +if ($Disable) { + Set-ItemProperty -Path $key -Name fDenyTSConnections -Value 1 + Write-Host 'the remote desktop is off' + return +} + +Set-ItemProperty -Path $key -Name fDenyTSConnections -Value 0 +# a session of the remote desktop is not let to drive the console at the same +# time, so that the two do not fight over the mouse +Set-ItemProperty -Path $winlogon -Name fSingleSessionPerUser -Value 1 -ErrorAction SilentlyContinue + +Set-Service -Name TermService -StartupType Automatic +Start-Service -Name TermService + +if ($OpenFirewall) { + if (-not (Get-NetFirewallRule -DisplayName 'RustNotMC remote desktop' -ErrorAction SilentlyContinue)) { + New-NetFirewallRule -DisplayName 'RustNotMC remote desktop' ` + -Direction Inbound -Protocol TCP -LocalPort 3389 -Action Allow -Profile Private | Out-Null + Write-Host 'the port 3389 is open on the private network' + } +} else { + Write-Host 'the port 3389 is not open on the network: the tunnel reaches it through the loopback' +} + +Write-Host '' +Write-Host 'the remote desktop is on. To reach it:' +Write-Host ' tools\tunnel.ps1 -LocalPort 3389 -Remote 3389' +Write-Host ' mstsc
: