# Скрипт: radmin-register.ps1 # Версия: 1.0.0 # Дата: 2026-05-27 # Описание: Регистрация (патч) Radmin Server через подмену библиотек # newtstop.dll → wsock32.dll и nts64helper.dll. # Скачивает патчи с GitHub-репозитория tarakan1983/MyAfterInstall. # # Использование (онлайн): # irm https://ps.gper.ru/ext/radmin-register.ps1 | iex # # Требования: PowerShell 5.0+, права администратора, установленный Radmin Server. $ErrorActionPreference = 'Stop' # ==================== КОНФИГУРАЦИЯ ==================== $RADMIN_SERVICE = 'RServer3' $RADMIN_PROCS = @('rserver3', 'FamItrfc') $PATCH_BASE_URL = 'https://raw.githubusercontent.com/tarakan1983/MyAfterInstall/refs/heads/main' $PATCH_FILES = @('newtstop.dll', 'nts64helper.dll') $TEMP_DIR = Join-Path $env:TEMP 'gper-radmin-patch' # ====================================================== # ==================== ХЕЛПЕРЫ ==================== function Test-IsAdmin { $id = [Security.Principal.WindowsIdentity]::GetCurrent() $pr = New-Object Security.Principal.WindowsPrincipal($id) return $pr.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) } function Get-RadminDir { # x64 ОС → SysWOW64\rserver30, x86 → System32\rserver30 if ([Environment]::Is64BitOperatingSystem) { $dir = Join-Path $env:WINDIR 'SysWOW64\rserver30' } else { $dir = Join-Path $env:WINDIR 'System32\rserver30' } if (-not (Test-Path -LiteralPath $dir)) { Write-Host "[X] Каталог Radmin не найден: $dir" -ForegroundColor Red return $null } return $dir } function Add-DriveExclusions { Write-Host '[i] Добавление исключений Defender (на время патча)...' -ForegroundColor Cyan 67..90 | ForEach-Object { $drive = [char]$_ $path = "${drive}:\" if (Test-Path -LiteralPath $path) { try { Add-MpPreference -ExclusionPath $path -ErrorAction Stop Add-MpPreference -ExclusionProcess "${path}*" -ErrorAction Stop } catch { # игнор — Defender может быть отключён } } } } function Remove-DriveExclusions { Write-Host '[i] Удаление временных исключений Defender...' -ForegroundColor Cyan 67..90 | ForEach-Object { $drive = [char]$_ $path = "${drive}:\" if (Test-Path -LiteralPath $path) { try { Remove-MpPreference -ExclusionPath $path -ErrorAction Stop Remove-MpPreference -ExclusionProcess "${path}*" -ErrorAction Stop } catch {} } } } function Add-PermanentExclusion { param([string]$Path) try { Add-MpPreference -ExclusionPath $Path -ErrorAction Stop Write-Host " [+] Defender exclusion: $Path" -ForegroundColor DarkGray } catch { Write-Host " [!] Не удалось добавить исключение для $Path" -ForegroundColor DarkYellow } } function Stop-RadminProcesses { Write-Host '[i] Остановка службы и процессов Radmin...' -ForegroundColor Cyan $svc = Get-Service -Name $RADMIN_SERVICE -ErrorAction SilentlyContinue if ($svc) { try { Stop-Service -Name $RADMIN_SERVICE -Force -ErrorAction Stop Write-Host " [OK] Служба $RADMIN_SERVICE остановлена" -ForegroundColor Green } catch { Write-Host " [!] Не удалось остановить службу: $($_.Exception.Message)" -ForegroundColor Yellow } } else { Write-Host " [!] Служба $RADMIN_SERVICE не найдена" -ForegroundColor Yellow } foreach ($proc in $RADMIN_PROCS) { $running = Get-Process -Name $proc -ErrorAction SilentlyContinue if ($running) { try { Stop-Process -Name $proc -Force -ErrorAction Stop Write-Host " [OK] Процесс $proc завершён" -ForegroundColor Green } catch { Write-Host " [!] Не удалось завершить $proc" -ForegroundColor Yellow } } } Start-Sleep -Seconds 2 } function Start-RadminService { Write-Host '[i] Запуск службы Radmin...' -ForegroundColor Cyan try { Start-Service -Name $RADMIN_SERVICE -ErrorAction Stop Start-Sleep -Seconds 2 $svc = Get-Service -Name $RADMIN_SERVICE Write-Host " [OK] Статус: $($svc.Status)" -ForegroundColor Green return ($svc.Status -eq 'Running') } catch { Write-Host " [X] Ошибка запуска: $($_.Exception.Message)" -ForegroundColor Red return $false } } function Get-PatchFiles { if (-not (Test-Path $TEMP_DIR)) { New-Item -ItemType Directory -Path $TEMP_DIR -Force | Out-Null } [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $downloaded = @{} foreach ($file in $PATCH_FILES) { $url = "$PATCH_BASE_URL/$file" $dest = Join-Path $TEMP_DIR $file Write-Host "[i] Скачиваю $file..." -ForegroundColor Cyan try { Invoke-WebRequest -Uri $url -OutFile $dest -UseBasicParsing -ErrorAction Stop $downloaded[$file] = $dest Write-Host " [OK] $dest" -ForegroundColor Green } catch { Write-Host " [X] Ошибка загрузки $file`: $($_.Exception.Message)" -ForegroundColor Red return $null } } return $downloaded } function Install-RadminPatch { param( [hashtable]$Patches, [string]$RadminDir ) # newtstop.dll → wsock32.dll $src = $Patches['newtstop.dll'] $dst = Join-Path $RadminDir 'wsock32.dll' try { Copy-Item -LiteralPath $src -Destination $dst -Force -ErrorAction Stop Write-Host "[OK] Установлено: $dst" -ForegroundColor Green Add-PermanentExclusion -Path $dst } catch { Write-Host "[X] Не удалось скопировать wsock32.dll: $($_.Exception.Message)" -ForegroundColor Red return $false } # nts64helper.dll → только если есть fam64helper.exe $famHelper = Join-Path $RadminDir 'fam64helper.exe' if (Test-Path -LiteralPath $famHelper) { $src2 = $Patches['nts64helper.dll'] $dst2 = Join-Path $RadminDir 'nts64helper.dll' try { Copy-Item -LiteralPath $src2 -Destination $dst2 -Force -ErrorAction Stop Write-Host "[OK] Установлено: $dst2" -ForegroundColor Green Add-PermanentExclusion -Path $dst2 } catch { Write-Host "[!] Не удалось скопировать nts64helper.dll" -ForegroundColor Yellow } } else { Write-Host "[i] fam64helper.exe не найден — nts64helper.dll не нужен" -ForegroundColor DarkGray } return $true } # ==================== MAIN ==================== Write-Host '' Write-Host '╔════════════════════════════════════════╗' -ForegroundColor Cyan Write-Host '║ Radmin Server — регистрация (патч) ║' -ForegroundColor Cyan Write-Host '╚════════════════════════════════════════╝' -ForegroundColor Cyan Write-Host '' if (-not (Test-IsAdmin)) { Write-Host '[X] Требуются права администратора.' -ForegroundColor Red return } $radminDir = Get-RadminDir if (-not $radminDir) { Write-Host '[X] Radmin Server не установлен. Сначала запустите radmin-install.' -ForegroundColor Red return } Write-Host "[i] Каталог Radmin: $radminDir" -ForegroundColor Cyan # 1. Defender exclusions (временные) Add-DriveExclusions Add-PermanentExclusion -Path $radminDir try { # 2. Стоп службы/процессов Stop-RadminProcesses # 3. Скачивание патчей $patches = Get-PatchFiles if (-not $patches) { Write-Host '[X] Регистрация прервана.' -ForegroundColor Red return } # 4. Установка патчей if (-not (Install-RadminPatch -Patches $patches -RadminDir $radminDir)) { Write-Host '[X] Регистрация прервана.' -ForegroundColor Red return } } finally { # 5. Снять временные исключения и стартануть службу — в любом случае Remove-DriveExclusions # Очистка temp if (Test-Path $TEMP_DIR) { Remove-Item -Path $TEMP_DIR -Recurse -Force -ErrorAction SilentlyContinue } # 6. Запуск службы $ok = Start-RadminService Write-Host '' if ($ok) { Write-Host '[OK] Регистрация Radmin Server завершена успешно.' -ForegroundColor Green } else { Write-Host '[!] Регистрация выполнена, но служба не запущена. Проверьте вручную.' -ForegroundColor Yellow } }