# ============================================================ # RustDesk CLIENT SETUP # Zapusk: irm https://git.help-d.ru/helmut/auto-turning/raw/branch/main/rd_setup.ps1 | iex # ============================================================ $repo = "https://git.help-d.ru/helmut/auto-turning/raw/branch/main" $temp = "$env:TEMP\rd_setup" # RustDesk server config $RD_HOST = "95.81.124.153" $RD_KEY = "T2CieQYAOU+iSkFGTLkkuJBdoYF5lyv4vPAikNRvruo=" Write-Host "`n========== RUSTDESK SETUP ==========`n" -ForegroundColor Cyan # ============================================================ # 1. OTKLYuChENIE ANTIVIRUSA # ============================================================ Write-Host "[1/5] Antivirus disable..." -ForegroundColor Yellow Set-MpPreference -DisableRealtimeMonitoring $true -ErrorAction SilentlyContinue Set-MpPreference -DisableBehaviorMonitoring $true -ErrorAction SilentlyContinue Set-MpPreference -DisableBlockAtFirstSeen $true -ErrorAction SilentlyContinue Set-MpPreference -DisableIOAVProtection $true -ErrorAction SilentlyContinue Set-MpPreference -DisableArchiveScanning $true -ErrorAction SilentlyContinue Stop-Service -Name WinDefend -Force -ErrorAction SilentlyContinue Write-Host " Antivirus disabled" -ForegroundColor Green # ============================================================ # 2. POKACHIVANIE I USTANOVKA # ============================================================ Write-Host "[2/5] Download and install RustDesk..." -ForegroundColor Yellow New-Item -ItemType Directory -Path $temp -Force | Out-Null # Nahodim fayl RustDesk v repo cherez API $repoApi = "$($repo -replace '/raw/branch/main', '')/api/v1/repos/helmut/auto-turning/contents/installers" try { $response = Invoke-WebRequest -Uri $repoApi -ErrorAction Stop $files = ($response.Content | ConvertFrom-Json) | Where-Object { $_.type -eq "file" -and $_.name -match "rustdesk" } if ($files.Count -eq 0) { Write-Host " RustDesk installer NOT found in repo" -ForegroundColor Red exit 1 } $rdFile = $files[0].name Write-Host " Found: $rdFile" -ForegroundColor Green } catch { # Fallback: esli API nedostupen, ishem lokalno ili po imeni $rdFile = "Rustdesk-1.4.4-x86_64.exe" Write-Host " Using default: $rdFile" -ForegroundColor Yellow } $rdUrl = "$repo/installers/$rdFile" $rdPath = "$temp\$rdFile" Write-Host " Downloading..." -ForegroundColor Gray Invoke-WebRequest -Uri $rdUrl -OutFile $rdPath -ErrorAction Stop Write-Host " Downloaded" -ForegroundColor Green Write-Host " Installing..." -ForegroundColor Gray $result = Start-Process $rdPath -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait -PassThru -NoNewWindow if ($result.ExitCode -eq 0 -or $result.ExitCode -eq 3010) { Write-Host " RustDesk installed" -ForegroundColor Green } else { Write-Host " Install error (code: $($result.ExitCode))" -ForegroundColor Yellow } # ============================================================ # 3. NASTROYKA RETRANSLyATORA (HOST + KEY) # ============================================================ Write-Host "[3/5] Configuring relay server..." -ForegroundColor Yellow # RustDesk hranit nastrojki v registru i v config-fajle # 1) Reestr (HKEY_LOCAL_MACHINE) — dlya vseh polzovatelej $rdRegPath = "HKLM:\SOFTWARE\RustDesk" if (-not (Test-Path $rdRegPath)) { New-Item -Path $rdRegPath -Force | Out-Null } # Proverayem kuda ustanovlen RustDesk $rdExePaths = @( "C:\Program Files\RustDesk\RustDesk.exe", "${env:ProgramFiles(x86)}\RustDesk\RustDesk.exe", "$env:LOCALAPPDATA\Programs\RustDesk\RustDesk.exe" ) $rdExe = $rdExePaths | Where-Object { Test-Path $_ } | Select-Object -First 1 if (-not $rdExe) { Write-Host " RustDesk.exe not found, trying registry config..." -ForegroundColor Yellow } # 2) Config fayl — RustDesk ispolzuet JSON/TOML config # Path: C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk2.toml # Ili dlya tekushchego polzovatelya: %APPDATA%\RustDesk\config\RustDesk2.toml $rdConfigDir = "$env:APPDATA\RustDesk\config" $rdConfigFile = "$rdConfigDir\RustDesk2.toml" # Sozdayem papku esli net New-Item -ItemType Directory -Path $rdConfigDir -Force | Out-Null # Proveryaem sushestvuet li config $createNew = $true if (Test-Path $rdConfigFile) { $createNew = $false Write-Host " Existing config found, updating..." -ForegroundColor Gray } # Formiruem soderzhimoe TOML $tomlContent = @" [options] custom-rendezvous-server = "$RD_HOST" relay-server = "$RD_HOST" key = "$RD_KEY" "@ $tomlContent | Set-Content $rdConfigFile -Encoding UTF8 -Force Write-Host " User config written" -ForegroundColor Green # Takzhe zapisyvaem v reestr dlya system-level if ($rdExe) { $rdDir = Split-Path $rdExe $systemConfigDir = "$rdDir\config" $systemConfigFile = "$systemConfigDir\RustDesk2.toml" New-Item -ItemType Directory -Path $systemConfigDir -Force | Out-Null $tomlContent | Set-Content $systemConfigFile -Encoding UTF8 -Force Write-Host " System config written" -ForegroundColor Green } # Registry keys (dlya avtozapuska servisa) $serviceRegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\rustdesk" $rustdeskService = Get-Service -Name "RustDesk" -ErrorAction SilentlyContinue if ($rustdeskService) { # Ostanavlivаем servis pered nastrojkoj Write-Host " Stopping RustDesk service..." -ForegroundColor Gray Stop-Service -Name "RustDesk" -Force -ErrorAction SilentlyContinue Start-Sleep -Seconds 2 # Zapuskem s nastrojkami Write-Host " Starting RustDesk service..." -ForegroundColor Gray Start-Service -Name "RustDesk" -ErrorAction SilentlyContinue Write-Host " RustDesk service restarted" -ForegroundColor Green } else { Write-Host " RustDesk service not found (running as app)" -ForegroundColor Yellow } # ============================================================ # 4. VKLYuChENIE ANTIVIRUSA # ============================================================ Write-Host "[4/5] Enabling antivirus..." -ForegroundColor Yellow Set-MpPreference -DisableRealtimeMonitoring $false -ErrorAction SilentlyContinue Set-MpPreference -DisableBehaviorMonitoring $false -ErrorAction SilentlyContinue Set-MpPreference -DisableBlockAtFirstSeen $false -ErrorAction SilentlyContinue Set-MpPreference -DisableIOAVProtection $false -ErrorAction SilentlyContinue Set-MpPreference -DisableArchiveScanning $false -ErrorAction SilentlyContinue Start-Service -Name WinDefend -ErrorAction SilentlyContinue Write-Host " Antivirus enabled" -ForegroundColor Green # ============================================================ # 5. ChISTKA # ============================================================ Write-Host "[5/5] Cleanup..." -ForegroundColor Yellow Remove-Item $temp -Recurse -Force -ErrorAction SilentlyContinue Write-Host " Temp files deleted" -ForegroundColor Green # ============================================================ # REZULTAT # ============================================================ Write-Host "`n==========================================" -ForegroundColor Green Write-Host " RUSTDESK SETUP COMPLETE" -ForegroundColor Green Write-Host "==========================================" -ForegroundColor Green Write-Host "`nRelay Server: $RD_HOST" -ForegroundColor Cyan Write-Host "Key: $RD_KEY" -ForegroundColor Cyan if ($rdExe) { Write-Host "`nRustDesk path: $rdExe" -ForegroundColor Yellow } Write-Host "`nZapustite RustDesk i podklyuchaytes cherez vash server." -ForegroundColor Green Write-Host ""