# ============================================================================ # RMS TECH - NVIDIA BOOST / Otimizacao para GPU NVIDIA # Interface + logica · by @rms.tech · distribuicao gratuita / free to share # Executado pelo RMS-TECH-NVIDIA-BOOST.bat (nao rode este .ps1 direto). # ============================================================================ $ErrorActionPreference = 'Stop' # --- pasta do script / script folder ------------------------------------ $ScriptDir = $PSScriptRoot if (-not $ScriptDir) { $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path } try { Set-Location -LiteralPath $ScriptDir } catch {} try { [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 } catch {} # --- liga cores ANSI 24-bit no console classico / enable truecolor ----- if (-not $env:WT_SESSION) { try { Add-Type -Namespace RmsVT -Name Native -MemberDefinition '[DllImport("kernel32.dll")] public static extern IntPtr GetStdHandle(int h); [DllImport("kernel32.dll")] public static extern bool GetConsoleMode(IntPtr h, out uint m); [DllImport("kernel32.dll")] public static extern bool SetConsoleMode(IntPtr h, uint m);' $hOut = [RmsVT.Native]::GetStdHandle(-11) $cmode = [uint32]0 [void][RmsVT.Native]::GetConsoleMode($hOut, [ref]$cmode) [void][RmsVT.Native]::SetConsoleMode($hOut, $cmode -bor 0x0004) } catch {} } # --- tamanho da janela / window size (best effort) -------------------- try { $ui = $Host.UI.RawUI $mx = $ui.MaxPhysicalWindowSize $cols = [Math]::Min(104, [int]$mx.Width) $rws = [Math]::Min(46, [int]$mx.Height) $bs = $ui.BufferSize; if ($bs.Width -lt $cols) { $bs.Width = $cols }; $bs.Height = 3000; $ui.BufferSize = $bs $ws = $ui.WindowSize; $ws.Width = $cols; $ws.Height = $rws; $ui.WindowSize = $ws } catch {} # --- paleta / palette -------------------------------------------------- $ESC = [char]27 $RS = "$ESC[0m" $BLD = "$ESC[1m" function fg ($r, $g, $b) { "$ESC[38;2;$r;$g;${b}m" } function bgc ($r, $g, $b) { "$ESC[48;2;$r;$g;${b}m" } $CY = fg 90 210 255 $MG = fg 200 100 255 $GR = fg 90 230 150 $RD = fg 255 100 115 $YL = fg 255 205 100 $DM = fg 120 126 145 $WH = fg 236 239 246 $TX = fg 205 210 226 $DOT = [char]183 $PTR = [char]187 $AUP = [char]24 $ADN = [char]25 # --- banner (fonte ANSI Shadow, chars CP437-safe) ------------------- $RMS = @( '██████╗ ███╗ ███╗███████╗', '██╔══██╗████╗ ████║██╔════╝', '██████╔╝██╔████╔██║███████╗', '██╔══██╗██║╚██╔╝██║╚════██║', '██║ ██║██║ ╚═╝ ██║███████║', '╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝') $TECH = @( '████████╗███████╗ ██████╗██╗ ██╗', '╚══██╔══╝██╔════╝██╔════╝██║ ██║', ' ██║ █████╗ ██║ ███████║', ' ██║ ██╔══╝ ██║ ██╔══██║', ' ██║ ███████╗╚██████╗██║ ██║', ' ╚═╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝') function GradBlock ($arr, $c1, $c2, $ind) { $n = $arr.Count for ($i = 0; $i -lt $n; $i++) { if ($n -le 1) { $q = 0 } else { $q = $i / ($n - 1) } $cr = [int]($c1[0] + ($c2[0] - $c1[0]) * $q) $cg = [int]($c1[1] + ($c2[1] - $c1[1]) * $q) $cb = [int]($c1[2] + ($c2[2] - $c1[2]) * $q) Write-Host ((' ' * $ind) + (fg $cr $cg $cb) + $arr[$i] + $RS) } } function Header { try { Clear-Host } catch {} Write-Host '' GradBlock $RMS @(95, 215, 255) @(150, 130, 255) 6 GradBlock $TECH @(150, 130, 255) @(210, 95, 255) 6 Write-Host '' Write-Host (' ' + $DM + ('─' * 58) + $RS) Write-Host (' ' + $WH + $BLD + 'NVIDIA BOOST' + $RS + $DM + " Otimizacao para GPU NVIDIA $DOT NVIDIA GPU Optimization" + $RS) Write-Host (' ' + $DM + 'by ' + $RS + $MG + $BLD + '@rms.tech' + $RS + $DM + " $DOT distribuicao gratuita" + $RS) Write-Host '' } # --- menu com setas / arrow-key menu ------------------------------- function Menu ($items, $title) { $sel = 0 $w = 58 while ($true) { Header if ($title) { Write-Host (' ' + $YL + $title + $RS); Write-Host '' } Write-Host (' ' + $DM + '┌' + ('─' * $w) + '┐' + $RS) Write-Host (' ' + $DM + '│' + (' ' * $w) + '│' + $RS) for ($i = 0; $i -lt $items.Count; $i++) { $lab = ' ' + $items[$i].Key + ' ' + $items[$i].Text if ($i -eq $sel) { $cell = ' ' + $PTR + ' ' + $lab $cell = $cell + (' ' * [Math]::Max(0, $w - $cell.Length)) Write-Host (' ' + $DM + '│' + $RS + (bgc 38 44 62) + (fg 130 232 255) + $BLD + $cell + $RS + $DM + '│' + $RS) } else { $cell = ' ' + $lab $cell = $cell + (' ' * [Math]::Max(0, $w - $cell.Length)) Write-Host (' ' + $DM + '│' + $RS + $TX + $cell + $RS + $DM + '│' + $RS) } } Write-Host (' ' + $DM + '│' + (' ' * $w) + '│' + $RS) Write-Host (' ' + $DM + '└' + ('─' * $w) + '┘' + $RS) Write-Host '' Write-Host (' ' + $DM + "$AUP $ADN" + $RS + $TX + ' navegar ' + $RS + $DM + 'Enter' + $RS + $TX + ' confirmar ' + $RS + $DM + 'Esc' + $RS + $TX + ' voltar' + $RS) $k = [Console]::ReadKey($true) if ($k.Key -eq 'UpArrow') { $sel = ($sel - 1 + $items.Count) % $items.Count; continue } if ($k.Key -eq 'DownArrow') { $sel = ($sel + 1) % $items.Count; continue } if ($k.Key -eq 'Enter') { return $items[$sel].Id } if ($k.Key -eq 'Escape') { return 'BACK' } foreach ($it in $items) { if ($it.Key -ne '' -and ([string]$k.KeyChar -eq [string]$it.Key)) { return $it.Id } } } } # --- helpers de status / status helpers --------------------------- function SLine ($txt) { Write-Host (' ' + $DM + ' ... ' + $RS + $TX + $txt + $RS) -NoNewline } function SOk ($txt) { Write-Host ("`r" + $ESC + '[2K' + ' ' + (bgc 30 90 55) + $GR + $BLD + ' OK ' + $RS + ' ' + $TX + $txt + $RS) } function SFail ($txt) { Write-Host ("`r" + $ESC + '[2K' + ' ' + (bgc 100 35 40) + $RD + $BLD + ' ERRO ' + $RS + ' ' + $TX + $txt + $RS) } function SWarn ($txt) { Write-Host ("`r" + $ESC + '[2K' + ' ' + (bgc 95 75 20) + $YL + $BLD + ' AVISO ' + $RS + ' ' + $TX + $txt + $RS) } function Bar ($total, $done) { $wd = 34 if ($total -le 0) { $f = 0 } else { $f = [int][Math]::Round($wd * $done / $total) } ' ' + $CY + ('█' * $f) + $DM + ('░' * ($wd - $f)) + $RS + $TX + (' {0}/{1}' -f $done, $total) + $RS } function GBox ($lines, $col) { $lines = @($lines) $w = 50 Write-Host (' ' + $col + $BLD + '╔' + ('═' * $w) + '╗' + $RS) foreach ($l in $lines) { $s = ' ' + $l if ($s.Length -gt $w) { $s = $s.Substring(0, $w) } $s = $s + (' ' * ($w - $s.Length)) Write-Host (' ' + $col + $BLD + '║' + $s + '║' + $RS) } Write-Host (' ' + $col + $BLD + '╚' + ('═' * $w) + '╝' + $RS) } function Pause2 { Write-Host '' Write-Host (' ' + $DM + 'pressione qualquer tecla para voltar ao menu...' + $RS) [void][Console]::ReadKey($true) } # --- executa reg.exe silencioso / run reg.exe quietly ------------ function RegRun { param([Parameter(ValueFromRemainingArguments = $true)] $a) $old = $ErrorActionPreference $ErrorActionPreference = 'SilentlyContinue' try { $null = & reg @a 2>&1 } catch {} $ok = ($LASTEXITCODE -eq 0) $ErrorActionPreference = $old return $ok } # --- chave do servico de telemetria NVIDIA / NVIDIA telemetry service key -- $NVTELE = 'HKLM\SYSTEM\CurrentControlSet\Services\NvTelemetryContainer' # --- lista de tweaks / tweak list ------------------------------- function Tweaks { $games = 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games' @( @{ K = 'HKCU\System\GameConfigStore'; N = 'GameDVR_Enabled'; T = 'REG_DWORD'; D = '0'; L = 'Game DVR desligado'; Req = $false } @{ K = 'HKCU\System\GameConfigStore'; N = 'GameDVR_FSEBehaviorMode'; T = 'REG_DWORD'; D = '2'; L = 'FSE behavior mode = 2'; Req = $false } @{ K = 'HKLM\SYSTEM\CurrentControlSet\Control\Power\PowerThrottling'; N = 'PowerThrottlingOff'; T = 'REG_DWORD'; D = '1'; L = 'Power Throttling desligado'; Req = $false } @{ K = 'HKLM\SOFTWARE\Microsoft\Windows\Dwm'; N = 'OverlayTestMode'; T = 'REG_DWORD'; D = '5'; L = 'DWM OverlayTestMode = 5'; Req = $false } @{ K = 'HKLM\SYSTEM\CurrentControlSet\Control\GraphicsDrivers'; N = 'HwSchMode'; T = 'REG_DWORD'; D = '2'; L = 'Hardware-accelerated GPU Scheduling = ON'; Req = $false } @{ K = $games; N = 'GPU Priority'; T = 'REG_DWORD'; D = '8'; L = 'Games: GPU Priority = 8'; Req = $false } @{ K = $games; N = 'Priority'; T = 'REG_DWORD'; D = '6'; L = 'Games: Priority = 6'; Req = $false } @{ K = $games; N = 'Scheduling Category'; T = 'REG_SZ'; D = 'High'; L = 'Games: Scheduling Category = High'; Req = $false } @{ K = $games; N = 'SFIO Priority'; T = 'REG_SZ'; D = 'High'; L = 'Games: SFIO Priority = High'; Req = $false } @{ K = $NVTELE; N = 'Start'; T = 'REG_DWORD'; D = '4'; L = 'NVIDIA Telemetry (NvTelemetryContainer) desativado'; Req = $true } ) } # --- tela de confirmacao / confirm screen -------------------- function Confirm { Header $w = 58 Write-Host (' ' + $YL + 'Isto sera gravado no Registro do Windows:' + $RS) Write-Host '' $rows = @( 'GameConfigStore GameDVR_Enabled 0', 'GameConfigStore GameDVR_FSEBehaviorMode 2', 'PowerThrottling PowerThrottlingOff 1', 'Dwm OverlayTestMode 5', 'GraphicsDrivers HwSchMode (HAGS) 2', 'Tasks\Games GPU Priority 8', 'Tasks\Games Priority 6', 'Tasks\Games Scheduling Category High', 'Tasks\Games SFIO Priority High', 'Services\NvTelemetryContainer Start 4') Write-Host (' ' + $DM + '┌' + ('─' * $w) + '┐' + $RS) foreach ($r in $rows) { $s = ' ' + $r $s = $s + (' ' * [Math]::Max(0, $w - $s.Length)) Write-Host (' ' + $DM + '│' + $RS + $TX + $s + $RS + $DM + '│' + $RS) } Write-Host (' ' + $DM + '└' + ('─' * $w) + '┘' + $RS) Write-Host '' Write-Host (' ' + $DM + 'HAGS deixa a GPU gerenciar a fila de video (efeito' + $RS) Write-Host (' ' + $DM + 'varia por placa/driver). Telemetria so e desativada' + $RS) Write-Host (' ' + $DM + 'se o servico existir no seu PC (NVIDIA App instalado).' + $RS) Write-Host '' Write-Host (' ' + $DM + 'backup .reg em ' + $RS + (fg 170 176 196) + (Join-Path $ScriptDir 'Backup_RMS_NVIDIA') + $RS) Write-Host '' Write-Host (' ' + (bgc 30 90 55) + $BLD + ' S ' + $RS + $TX + ' aplicar agora ' + $RS + (bgc 100 35 40) + $BLD + ' N ' + $RS + $TX + ' cancelar' + $RS) while ($true) { $k = [Console]::ReadKey($true) $c = [string]$k.KeyChar if ($c -match '^[sySY]$') { return $true } if ($c -match '^[nN]$' -or $k.Key -eq 'Escape') { return $false } } } # --- aplicar / apply --------------------------------------- function RunApply { Header Write-Host (' ' + $WH + $BLD + "1 $DOT BACKUP" + $RS) Write-Host '' $stamp = Get-Date -Format 'yyyy-MM-dd_HH-mm-ss' $bkdir = Join-Path (Join-Path $ScriptDir 'Backup_RMS_NVIDIA') $stamp New-Item -ItemType Directory -Force -Path $bkdir | Out-Null $bkeys = @( @{ K = 'HKCU\System\GameConfigStore'; F = 'GameConfigStore.reg' } @{ K = 'HKLM\SYSTEM\CurrentControlSet\Control\Power\PowerThrottling'; F = 'PowerThrottling.reg' } @{ K = 'HKLM\SOFTWARE\Microsoft\Windows\Dwm'; F = 'Dwm.reg' } @{ K = 'HKLM\SYSTEM\CurrentControlSet\Control\GraphicsDrivers'; F = 'GraphicsDrivers.reg' } @{ K = 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games'; F = 'Tasks_Games.reg' } @{ K = $NVTELE; F = 'NvTelemetryContainer.reg' } ) foreach ($x in $bkeys) { SLine $x.F Start-Sleep -Milliseconds 55 if (RegRun query $x.K) { if (RegRun export $x.K (Join-Path $bkdir $x.F) /y) { SOk ('backup ' + $x.F) } else { SWarn ('sem backup ' + $x.F) } } else { Set-Content -LiteralPath (Join-Path $bkdir ('MISSING_' + $x.F + '.txt')) -Value $x.K -Encoding ASCII SWarn ('nao existia, ok ' + $x.F) } } Write-Host '' Write-Host (' ' + $WH + $BLD + "2 $DOT APLICANDO / APPLYING" + $RS) Write-Host '' $tw = Tweaks $done = 0; $fail = 0; $skip = 0 foreach ($t in $tw) { if ($t.Req -and -not (RegRun query $t.K)) { SWarn ('nao encontrado, pulado ' + $t.L) $skip++ continue } SLine $t.L Start-Sleep -Milliseconds 70 if (RegRun add $t.K /v $t.N /t $t.T /d $t.D /f) { SOk $t.L; $done++ } else { SFail $t.L; $fail++ } } if ($done -gt 0) { try { Stop-Service -Name 'NvTelemetryContainer' -Force -ErrorAction SilentlyContinue } catch {} } Write-Host '' Write-Host (Bar $tw.Count $done) Write-Host '' if ($fail -eq 0) { GBox @( "TWEAKS APLICADOS $DOT REINICIE O PC", "TWEAKS APPLIED $DOT RESTART YOUR PC") $GR } else { GBox @("$fail item(s) falharam.", 'Feche e rode como administrador.') $YL } if ($skip -gt 0) { Write-Host (' ' + $DM + ($skip.ToString() + ' item(s) pulado(s): servico nao encontrado neste PC.') + $RS) } Write-Host '' Write-Host (' ' + $DM + 'backup: ' + $RS + (fg 170 176 196) + $bkdir + $RS) Write-Host '' Write-Host (' ' + $MG + $BLD + 'curtiu? compartilha com a galera e segue @rms.tech' + $RS) try { Start-Process 'https://otimizar.superpackultimate.com/?de=packs' } catch {} Pause2 } # --- restaurar / restore -------------------------------- function RunRestore { Header Write-Host (' ' + $WH + $BLD + 'RESTAURAR / RESTORE' + $RS) Write-Host '' $bkroot = Join-Path $ScriptDir 'Backup_RMS_NVIDIA' if (-not (Test-Path -LiteralPath $bkroot)) { GBox @('Nenhum backup encontrado.', 'No backup found.') $RD Pause2; return } $latest = Get-ChildItem -LiteralPath $bkroot -Directory -ErrorAction SilentlyContinue | Sort-Object Name -Descending | Select-Object -First 1 if (-not $latest) { GBox @('Nenhum backup encontrado.', 'No backup found.') $RD Pause2; return } Write-Host (' ' + $DM + 'de / from: ' + $RS + (fg 170 176 196) + $latest.FullName + $RS) Write-Host '' Write-Host (' ' + $WH + $BLD + 'removendo valores adicionados / removing added values' + $RS) Write-Host '' foreach ($t in (Tweaks)) { SLine ('remover ' + $t.N) Start-Sleep -Milliseconds 40 [void](RegRun delete $t.K /v $t.N /f) SOk ('removido ' + $t.N) } Write-Host '' Write-Host (' ' + $WH + $BLD + 'reimportando originais / re-importing originals' + $RS) Write-Host '' $imported = 0 Get-ChildItem -LiteralPath $latest.FullName -Filter *.reg -ErrorAction SilentlyContinue | ForEach-Object { SLine ('import ' + $_.Name) Start-Sleep -Milliseconds 40 if (RegRun import $_.FullName) { SOk ('import ' + $_.Name); $imported++ } else { SFail ('import ' + $_.Name) } } if ($imported -eq 0) { Write-Host (' ' + $DM + ' (nenhum .reg neste backup)' + $RS) } if (Test-Path -LiteralPath (Join-Path $latest.FullName 'MISSING_PowerThrottling.reg.txt')) { [void](RegRun delete 'HKLM\SYSTEM\CurrentControlSet\Control\Power\PowerThrottling' /f) SWarn 'chave PowerThrottling removida (nao existia antes)' } if (Test-Path -LiteralPath (Join-Path $latest.FullName 'MISSING_NvTelemetryContainer.reg.txt')) { [void](RegRun delete $NVTELE /f) SWarn 'chave NvTelemetryContainer removida (nao existia antes)' } Write-Host '' GBox @("RESTAURADO $DOT REINICIE O PC", "RESTORED $DOT RESTART YOUR PC") $GR Pause2 } # ============================ MAIN ===================================== try { [Console]::CursorVisible = $false } catch {} try { while ($true) { $c = Menu @( @{ Id = 'APPLY'; Key = '1'; Text = "Aplicar otimizacoes $DOT Apply tweaks" } @{ Id = 'RESTORE'; Key = '2'; Text = "Restaurar ultimo backup $DOT Restore backup" } @{ Id = 'EXIT'; Key = '3'; Text = "Sair $DOT Exit" } ) '' if ($c -eq 'APPLY') { if (Confirm) { RunApply } } elseif ($c -eq 'RESTORE') { RunRestore } elseif ($c -eq 'EXIT' -or $c -eq 'BACK') { break } } } finally { try { [Console]::CursorVisible = $true } catch {} Write-Host $RS Write-Host '' }