# ============================================================ # 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 # Opredelyaem razryadnost sistemy $arch = (Get-WmiObject -Class Win32_OperatingSystem -ErrorAction SilentlyContinue).OSArchitecture if ($arch -match "32") { $isX86 = $true Write-Host " Architecture: x86 (32-bit)" -ForegroundColor Gray } else { $isX86 = $false Write-Host " Architecture: x64 (64-bit)" -ForegroundColor Gray } # 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 $allFiles = ($response.Content | ConvertFrom-Json) | Where-Object { $_.type -eq "file" } # Vibiraem nuzhnyj fayl po arhitekture if ($isX86) { $rdFile = ($allFiles | Where-Object { $_.name -match "rustdesk.*x86.*sciter" } | Select-Object -First 1).name if (-not $rdFile) { $rdFile = ($allFiles | Where-Object { $_.name -match "rustdesk.*x86" } | Select-Object -First 1).name } } else { $rdFile = ($allFiles | Where-Object { $_.name -match "rustdesk.*x86_64" } | Select-Object -First 1).name } if (-not $rdFile) { $rdFile = ($allFiles | Where-Object { $_.name -match "rustdesk" } | Select-Object -First 1).name } if (-not $rdFile) { Write-Host " RustDesk installer NOT found in repo" -ForegroundColor Red exit 1 } Write-Host " Selected: $rdFile" -ForegroundColor Green } catch { if ($isX86) { $rdFile = "rustdesk-1.4.6-x86-sciter.exe" } else { $rdFile = "rustdesk-1.4.6-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 # Formiruem TOML config $tomlContent = @" [options] custom-rendezvous-server = "$RD_HOST" relay-server = "$RD_HOST" key = "$RD_KEY" "@ # Nahodim RustDesk.exe $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" -ForegroundColor Red Write-Host " Skipping config..." -ForegroundColor Yellow } else { Write-Host " Found: $rdExe" -ForegroundColor Green # Ostanavlivаем vse processy i servisy RustDesk chtoby ne perenezli config Write-Host " Stopping RustDesk processes..." -ForegroundColor Gray Get-Process -Name "RustDesk" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue Stop-Service -Name "RustDesk" -Force -ErrorAction SilentlyContinue Stop-Service -Name "RustDesk Tray" -Force -ErrorAction SilentlyContinue Start-Sleep -Seconds 3 # === 1) Config dlya tekushchego polzovatelya === $userConfigDir = "$env:APPDATA\RustDesk\config" $userConfigFile = "$userConfigDir\RustDesk2.toml" New-Item -ItemType Directory -Path $userConfigDir -Force | Out-Null $tomlContent | Set-Content $userConfigFile -Encoding UTF8 -Force Write-Host " User config: OK" -ForegroundColor Green # === 2) Config dlya servisa (LocalService) === $svcConfigDir = "C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config" $svcConfigFile = "$svcConfigDir\RustDesk2.toml" New-Item -ItemType Directory -Path $svcConfigDir -Force | Out-Null $tomlContent | Set-Content $svcConfigFile -Encoding UTF8 -Force Write-Host " Service config: OK" -ForegroundColor Green # === 3) Config ryadom s exe (system-level) === $rdDir = Split-Path $rdExe $exeConfigDir = "$rdDir\config" $exeConfigFile = "$exeConfigDir\RustDesk2.toml" New-Item -ItemType Directory -Path $exeConfigDir -Force | Out-Null $tomlContent | Set-Content $exeConfigFile -Encoding UTF8 -Force Write-Host " EXE config: OK" -ForegroundColor Green # === 4) Reestr HKLM === $rdRegPath = "HKLM:\SOFTWARE\RustDesk" if (-not (Test-Path $rdRegPath)) { New-Item -Path $rdRegPath -Force | Out-Null } Set-ItemProperty -Path $rdRegPath -Name "CustomRelayServer" -Value "$RD_HOST" -Force -ErrorAction SilentlyContinue Set-ItemProperty -Path $rdRegPath -Name "RelayServer" -Value "$RD_HOST" -Force -ErrorAction SilentlyContinue Set-ItemProperty -Path $rdRegPath -Name "Key" -Value "$RD_KEY" -Force -ErrorAction SilentlyContinue Write-Host " Registry: OK" -ForegroundColor Green # === 5) Reestr HKCU === $rdRegPathCU = "HKCU:\SOFTWARE\RustDesk" if (-not (Test-Path $rdRegPathCU)) { New-Item -Path $rdRegPathCU -Force | Out-Null } Set-ItemProperty -Path $rdRegPathCU -Name "CustomRelayServer" -Value "$RD_HOST" -Force -ErrorAction SilentlyContinue Set-ItemProperty -Path $rdRegPathCU -Name "RelayServer" -Value "$RD_HOST" -Force -ErrorAction SilentlyContinue Set-ItemProperty -Path $rdRegPathCU -Name "Key" -Value "$RD_KEY" -Force -ErrorAction SilentlyContinue Write-Host " Registry (user): OK" -ForegroundColor Green # === 6) Zapusk s parametrami dlya primeneniya === Write-Host " Applying config via CLI..." -ForegroundColor Gray Start-Process $rdExe -ArgumentList "--config-server=$RD_HOST","--key=$RD_KEY" -Wait -PassThru -NoNewWindow -ErrorAction SilentlyContinue Start-Sleep -Seconds 3 # Ostanavlivaem chtoby servis mog zapustitsya chisto Get-Process -Name "RustDesk" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue Start-Sleep -Seconds 2 # Zapuskem servis $rustdeskService = Get-Service -Name "RustDesk" -ErrorAction SilentlyContinue if ($rustdeskService) { Start-Service -Name "RustDesk" -ErrorAction SilentlyContinue Write-Host " Service: started" -ForegroundColor Green } } # ============================================================ # 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: $rdExe" -ForegroundColor Yellow } Write-Host "`nRustDesk gotov k rabote cherez vash server." -ForegroundColor Green Write-Host ""