# ============================================================================ # RMS TECH - CPU BOOST / CPU 100% nos jogos: stutter e queda de FPS # Interface + logica · by @rms.tech · distribuicao gratuita / free to share # Executado pelo RMS-TECH-CPU-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 + 'CPU BOOST' + $RS + $DM + " CPU 100% / Stutter $DOT CPU 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 } # --- plano de energia / power plan -------------------------------- function GetActiveSchemeText { $old = $ErrorActionPreference $ErrorActionPreference = 'SilentlyContinue' $o = '' try { $o = (& powercfg /getactivescheme 2>&1 | Out-String) } catch {} $ErrorActionPreference = $old return $o } function GetActiveScheme { $o = GetActiveSchemeText if ($o -match '([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})') { return $Matches[1] } return '' } function SetScheme ($s) { $old = $ErrorActionPreference $ErrorActionPreference = 'SilentlyContinue' try { $null = & powercfg /setactive $s 2>&1 } catch {} $ok = ($LASTEXITCODE -eq 0) $ErrorActionPreference = $old return $ok } # --- chaves / keys ------------------------------------------------- $K_GBAR = 'HKCU\Software\Microsoft\GameBar' $K_GCS = 'HKCU\System\GameConfigStore' $K_GDVR = 'HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR' $K_GDVRPOL = 'HKLM\SOFTWARE\Policies\Microsoft\Windows\GameDVR' $K_BGAPP = 'HKCU\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications' $K_PTHR = 'HKLM\SYSTEM\CurrentControlSet\Control\Power\PowerThrottling' $K_GAMES = 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games' $BkRoot = Join-Path $ScriptDir 'Backup_RMS_CPU' $StartupState = Join-Path $BkRoot 'Startup_State.json' $LinkUrl = 'https://otimizar.superpackultimate.com/?de=packs' # Del = apaga o valor no "Restaurar" antes de reimportar o backup function Tweaks { @( @{ K = $K_GBAR; N = 'AutoGameModeEnabled'; T = 'REG_DWORD'; D = '1'; L = 'Modo de Jogo ligado (AutoGameModeEnabled)' } @{ K = $K_GBAR; N = 'AllowAutoGameMode'; T = 'REG_DWORD'; D = '1'; L = 'Modo de Jogo automatico (AllowAutoGameMode)' } @{ K = $K_GCS; N = 'GameDVR_Enabled'; T = 'REG_DWORD'; D = '0'; L = 'Captura do Windows: GameDVR_Enabled = 0' } @{ K = $K_GDVR; N = 'AppCaptureEnabled'; T = 'REG_DWORD'; D = '0'; L = 'Captura do Windows: AppCaptureEnabled = 0' } @{ K = $K_GDVRPOL; N = 'AllowGameDVR'; T = 'REG_DWORD'; D = '0'; L = 'Captura do Windows: AllowGameDVR = 0' } @{ K = $K_BGAPP; N = 'GlobalUserDisabled'; T = 'REG_DWORD'; D = '1'; L = 'Apps UWP em segundo plano desligados' } @{ K = $K_PTHR; N = 'PowerThrottlingOff'; T = 'REG_DWORD'; D = '1'; L = 'Power Throttling desligado' } @{ K = $K_GAMES; N = 'GPU Priority'; T = 'REG_DWORD'; D = '8'; L = 'Games: GPU Priority = 8' } @{ K = $K_GAMES; N = 'Priority'; T = 'REG_DWORD'; D = '6'; L = 'Games: Priority = 6' } @{ K = $K_GAMES; N = 'Scheduling Category'; T = 'REG_SZ'; D = 'High'; L = 'Games: Scheduling Category = High' } @{ K = $K_GAMES; N = 'SFIO Priority'; T = 'REG_SZ'; D = 'High'; L = 'Games: SFIO Priority = High' } ) } # =========================================================================== # PROGRAMAS DE INICIALIZACAO (mesmo mecanismo do Gerenciador de Tarefas) # =========================================================================== $StartupSources = @( @{ Run = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run'; Appr = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run' } @{ Run = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'; Appr = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run' } @{ Run = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run'; Appr = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run32' } ) # nunca listar: seguranca, audio, video, touchpad $StartupProtected = 'SecurityHealth|Defender|Windows Security|Rtk|Realtek|NVIDIA|NvBackend|NvContainer|Radeon|AMDNoise|AMD ?Software|Intel|igfx|Synaptics|Touchpad|ELAN|Bluetooth|Hotkey|Vanguard|vgtray|EasyAntiCheat|BattlEye|Driver' function ShortCmd ($cmd) { $c = [string]$cmd try { if ($c -match '^\s*"([^"]+)"') { return [IO.Path]::GetFileName($Matches[1]) } if ($c -match '^\s*(.+?\.exe)') { return [IO.Path]::GetFileName($Matches[1]) } } catch {} if ($c.Length -gt 24) { return $c.Substring(0, 24) } return $c } function GetStartupEntries { $out = @() foreach ($src in $StartupSources) { $props = $null try { $props = Get-ItemProperty -LiteralPath $src.Run -ErrorAction Stop } catch { continue } foreach ($p in $props.PSObject.Properties) { if ($p.Name -like 'PS*') { continue } $name = $p.Name $cmd = [string]$p.Value if ($name -match $StartupProtected -or $cmd -match $StartupProtected) { continue } $enabled = $true try { $b = (Get-ItemProperty -LiteralPath $src.Appr -Name $name -ErrorAction Stop).$name if ($b -is [byte[]] -and $b.Length -gt 0 -and (($b[0] -band 1) -eq 1)) { $enabled = $false } } catch {} if ($enabled) { $out += [pscustomobject]@{ Name = $name; Cmd = $cmd; Short = (ShortCmd $cmd); Appr = $src.Appr } } } } return $out } function ToHex ($bytes) { if ($null -eq $bytes) { return '' }; (($bytes | ForEach-Object { '{0:X2}' -f $_ }) -join '') } function FromHex ($hex) { $l = New-Object System.Collections.Generic.List[byte] for ($i = 0; $i + 1 -lt $hex.Length; $i += 2) { $l.Add([Convert]::ToByte($hex.Substring($i, 2), 16)) } return ,($l.ToArray()) } function LoadStartupState { if (-not (Test-Path -LiteralPath $StartupState)) { return @() } try { return @(Get-Content -LiteralPath $StartupState -Raw | ConvertFrom-Json) } catch { return @() } } function Checklist ($entries) { $cnt = $entries.Count $sel = New-Object 'bool[]' $cnt $pos = 0; $top = 0; $view = 14; $w = 58 while ($true) { Header Write-Host (' ' + $YL + 'Marque o que NAO precisa abrir junto com o Windows:' + $RS) Write-Host (' ' + $DM + 'Espaco marca/desmarca Enter aplica Esc cancela' + $RS) Write-Host '' Write-Host (' ' + $DM + '┌' + ('─' * $w) + '┐' + $RS) $n = [Math]::Min($view, $cnt - $top) for ($i = 0; $i -lt $n; $i++) { $idx = $top + $i $box = if ($sel[$idx]) { '[x]' } else { '[ ]' } $lab = ' ' + $box + ' ' + $entries[$idx].Name + ' ' + $DOT + ' ' + $entries[$idx].Short if ($idx -eq $pos) { $cell = ' ' + $PTR + $lab if ($cell.Length -gt $w) { $cell = $cell.Substring(0, $w) } $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 if ($cell.Length -gt $w) { $cell = $cell.Substring(0, $w) } $cell = $cell + (' ' * [Math]::Max(0, $w - $cell.Length)) Write-Host (' ' + $DM + '│' + $RS + $TX + $cell + $RS + $DM + '│' + $RS) } } Write-Host (' ' + $DM + '└' + ('─' * $w) + '┘' + $RS) $marked = 0; foreach ($b in $sel) { if ($b) { $marked++ } } Write-Host (' ' + $DM + ('item {0}/{1} marcados: {2}' -f ($pos + 1), $cnt, $marked) + $RS) $k = [Console]::ReadKey($true) if ($k.Key -eq 'UpArrow') { $pos = ($pos - 1 + $cnt) % $cnt } elseif ($k.Key -eq 'DownArrow') { $pos = ($pos + 1) % $cnt } elseif ($k.Key -eq 'Spacebar') { $sel[$pos] = -not $sel[$pos] } elseif ($k.Key -eq 'Enter') { $res = @(); for ($i = 0; $i -lt $cnt; $i++) { if ($sel[$i]) { $res += $entries[$i] } } return ,$res } elseif ($k.Key -eq 'Escape') { return $null } if ($pos -lt $top) { $top = $pos } if ($pos -ge $top + $view) { $top = $pos - $view + 1 } } } function RunStartup { Header Write-Host (' ' + $WH + $BLD + 'PROGRAMAS DE INICIALIZACAO / STARTUP APPS' + $RS) Write-Host '' $entries = @(GetStartupEntries) if ($entries.Count -eq 0) { GBox @('Nada para desativar na inicializacao.', 'Nothing to disable at startup.') $GR Write-Host (' ' + $DM + '(itens de seguranca, audio e video nunca sao listados)' + $RS) Pause2; return } $chosen = Checklist $entries if ($null -eq $chosen -or $chosen.Count -eq 0) { return } Header Write-Host (' ' + $WH + $BLD + 'DESATIVANDO / DISABLING' + $RS) Write-Host '' New-Item -ItemType Directory -Force -Path $BkRoot | Out-Null $state = [System.Collections.ArrayList]@(LoadStartupState) $done = 0 foreach ($e in $chosen) { SLine ('desativar ' + $e.Name) Start-Sleep -Milliseconds 60 try { $had = $false; $hex = '' try { $old = (Get-ItemProperty -LiteralPath $e.Appr -Name $e.Name -ErrorAction Stop).($e.Name) if ($old -is [byte[]]) { $had = $true; $hex = ToHex $old } } catch {} $already = $false foreach ($s in $state) { if ($s.Appr -eq $e.Appr -and $s.Name -eq $e.Name) { $already = $true; break } } if (-not $already) { [void]$state.Add([pscustomobject]@{ Appr = $e.Appr; Name = $e.Name; Had = $had; Hex = $hex }) } if (-not (Test-Path -LiteralPath $e.Appr)) { New-Item -Path $e.Appr -Force | Out-Null } $ft = [BitConverter]::GetBytes([DateTime]::Now.ToFileTime()) $bytes = [byte[]](3, 0, 0, 0) + $ft Set-ItemProperty -LiteralPath $e.Appr -Name $e.Name -Value $bytes -Type Binary SOk ('desativado ' + $e.Name) $done++ } catch { SFail ('falhou ' + $e.Name) } } ConvertTo-Json -InputObject @($state) | Set-Content -LiteralPath $StartupState -Encoding UTF8 Write-Host '' GBox @("$done programa(s) desativado(s)", 'Vale na proxima vez que ligar o PC.') $GR Write-Host (' ' + $DM + 'Voce pode reativar pelo Gerenciador de Tarefas ou em [4] Restaurar.' + $RS) Pause2 } function RestoreStartup { $state = LoadStartupState if ($state.Count -eq 0) { return 0 } $n = 0 foreach ($s in $state) { SLine ('reativar ' + $s.Name) Start-Sleep -Milliseconds 40 try { if ($s.Had -and $s.Hex) { Set-ItemProperty -LiteralPath $s.Appr -Name $s.Name -Value (FromHex $s.Hex) -Type Binary } else { Remove-ItemProperty -LiteralPath $s.Appr -Name $s.Name -ErrorAction SilentlyContinue } SOk ('reativado ' + $s.Name) $n++ } catch { SWarn ('nao consegui reativar ' + $s.Name) } } Remove-Item -LiteralPath $StartupState -Force -ErrorAction SilentlyContinue return $n } # =========================================================================== # DIAGNOSTICO DE CPU # =========================================================================== function RunDiag { Header Write-Host (' ' + $WH + $BLD + 'DIAGNOSTICO DE CPU / CPU DIAGNOSTIC' + $RS) Write-Host '' Write-Host (' ' + $DM + 'Dica: abra o jogo, de Alt+Tab e rode isto com ele aberto.' + $RS) Write-Host (' ' + $DM + 'Coletando amostras por alguns segundos...' + $RS) $ncpu = 0 try { $ncpu = [int](Get-CimInstance Win32_ComputerSystem -ErrorAction Stop).NumberOfLogicalProcessors } catch {} if ($ncpu -lt 1) { $ncpu = [Environment]::ProcessorCount } $agg = @{}; $coreSum = @{}; $coreMax = @{}; $totSum = 0.0; $n = 0 for ($s = 0; $s -lt 6; $s++) { $procs = @(); $cores = @() try { $procs = @(Get-CimInstance Win32_PerfFormattedData_PerfProc_Process -ErrorAction Stop) } catch {} try { $cores = @(Get-CimInstance Win32_PerfFormattedData_PerfOS_Processor -ErrorAction Stop) } catch {} if ($s -gt 0) { $n++ foreach ($p in $procs) { $nm = ($p.Name -replace '#\d+$', '') if ($nm -eq '_Total' -or $nm -eq 'Idle') { continue } if (-not $agg.ContainsKey($nm)) { $agg[$nm] = 0.0 } $agg[$nm] += [double]$p.PercentProcessorTime } foreach ($c in $cores) { $v = [double]$c.PercentProcessorTime if ($c.Name -eq '_Total') { $totSum += $v; continue } if (-not $coreSum.ContainsKey($c.Name)) { $coreSum[$c.Name] = 0.0; $coreMax[$c.Name] = 0.0 } $coreSum[$c.Name] += $v if ($v -gt $coreMax[$c.Name]) { $coreMax[$c.Name] = $v } } } Start-Sleep -Seconds 1 } if ($n -lt 1) { $n = 1 } $total = [Math]::Round($totSum / $n, 0) $hotAvg = 0.0; $hotPeak = 0.0 foreach ($k in $coreSum.Keys) { $a = $coreSum[$k] / $n if ($a -gt $hotAvg) { $hotAvg = $a } if ($coreMax[$k] -gt $hotPeak) { $hotPeak = $coreMax[$k] } } $hotAvg = [Math]::Round($hotAvg, 0); $hotPeak = [Math]::Round($hotPeak, 0) Header Write-Host (' ' + $WH + $BLD + 'DIAGNOSTICO DE CPU / CPU DIAGNOSTIC' + $RS) Write-Host '' try { $cpu = Get-CimInstance Win32_Processor -ErrorAction Stop | Select-Object -First 1 Write-Host (' ' + $TX + $cpu.Name.Trim() + $RS) Write-Host (' ' + $DM + ('{0} nucleos / {1} threads clock agora {2} MHz (base {3} MHz)' -f $cpu.NumberOfCores, $ncpu, $cpu.CurrentClockSpeed, $cpu.MaxClockSpeed) + $RS) } catch {} Write-Host '' $colT = if ($total -ge 90) { $RD } elseif ($total -ge 70) { $YL } else { $GR } Write-Host (' ' + $TX + 'Uso total da CPU: ' + $colT + $BLD + ('{0}%' -f $total) + $RS) $colH = if ($hotAvg -ge 95) { $RD } elseif ($hotAvg -ge 80) { $YL } else { $GR } Write-Host (' ' + $TX + 'Nucleo mais carregado: ' + $colH + $BLD + ('{0}%' -f $hotAvg) + $RS + $DM + (' (pico {0}%)' -f $hotPeak) + $RS) Write-Host '' Write-Host (' ' + $WH + $BLD + 'QUEM MAIS USA A CPU / TOP PROCESSES' + $RS) $top = $agg.GetEnumerator() | Sort-Object Value -Descending | Select-Object -First 8 foreach ($t in $top) { $pct = [Math]::Round(($t.Value / $n) / $ncpu, 1) $f = [int][Math]::Min(20, [Math]::Round($pct / 5)) $nm = $t.Name; if ($nm.Length -gt 28) { $nm = $nm.Substring(0, 28) } Write-Host (' ' + $TX + $nm.PadRight(30) + $CY + ('█' * $f) + $DM + ('░' * (20 - $f)) + $RS + $TX + (' {0,5}%' -f $pct) + $RS) } Write-Host '' Write-Host (' ' + $WH + $BLD + 'MEMORIA / RAM' + $RS) try { $mods = @(Get-CimInstance Win32_PhysicalMemory -ErrorAction Stop) $gb = [Math]::Round((($mods | Measure-Object Capacity -Sum).Sum) / 1GB, 0) $sp = ($mods | Select-Object -First 1).Speed $cf = ($mods | Select-Object -First 1).ConfiguredClockSpeed Write-Host (' ' + $TX + ('{0} pente(s), {1} GB no total, rodando a {2} MHz (nominal {3} MHz)' -f $mods.Count, $gb, $cf, $sp) + $RS) if ($mods.Count -eq 1) { Write-Host (' ' + $YL + 'Apenas 1 pente: single channel. Com 2 pentes (dual channel) a CPU rende mais nos jogos.' + $RS) } if ($cf -and $sp -and $cf -lt $sp) { Write-Host (' ' + $YL + 'RAM abaixo da velocidade nominal: confira o perfil XMP/EXPO na BIOS.' + $RS) } } catch { Write-Host (' ' + $DM + 'nao consegui ler a memoria.' + $RS) } Write-Host '' Write-Host (' ' + $WH + $BLD + 'WINDOWS' + $RS) $plan = '' if ((GetActiveSchemeText) -match '\(([^)]+)\)') { $plan = $Matches[1] } $gm = 'ligado' try { $v = (Get-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\GameBar' -Name AutoGameModeEnabled -ErrorAction Stop).AutoGameModeEnabled; if ($v -eq 0) { $gm = 'desligado' } } catch {} Write-Host (' ' + $TX + ('Plano de energia: {0} Modo de Jogo: {1}' -f $plan, $gm) + $RS) $build = [Environment]::OSVersion.Version.Build if ($build -lt 22000) { Write-Host (' ' + $YL + 'Windows 10: o suporte gratuito acabou em 14/10/2025 (ESU ou Windows 11).' + $RS) } Write-Host '' Write-Host (' ' + $WH + $BLD + 'LEITURA / READING' + $RS) if ($hotAvg -ge 95 -and $total -lt 80) { Write-Host (' ' + $YL + '- Poucos nucleos no limite com a CPU total livre: o jogo depende de' + $RS) Write-Host (' ' + $YL + ' poucos nucleos. Limitar o FPS e baixar distancia de visao ajuda.' + $RS) } if ($total -ge 90) { Write-Host (' ' + $RD + '- CPU quase toda ocupada: veja na lista se o 1o nao e o jogo.' + $RS) Write-Host (' ' + $RD + ' Se for outro programa, feche ou tire da inicializacao.' + $RS) } if ($total -lt 90 -and -not ($hotAvg -ge 95 -and $total -lt 80)) { Write-Host (' ' + $GR + '- Uso dentro do normal agora. Se travar, rode de novo com o jogo aberto.' + $RS) } Write-Host (' ' + $DM + '- Temperatura/clock: use HWiNFO; clock caindo com calor = throttling.' + $RS) Write-Host (' ' + $DM + '- CPU alta com GPU baixa e FPS instavel = provavel gargalo de CPU.' + $RS) Pause2 } # --- tela de confirmacao / confirm screen -------------------- function Confirm { Header $w = 58 Write-Host (' ' + $YL + 'Isto sera gravado no Registro do Windows:' + $RS) Write-Host '' $rows = @( 'GameBar AutoGameModeEnabled 1', 'GameBar AllowAutoGameMode 1', 'GameConfigStore GameDVR_Enabled 0', 'GameDVR AppCaptureEnabled 0', 'Policies\GameDVR AllowGameDVR 0', 'BackgroundApps GlobalUserDisabled 1', 'PowerThrottling PowerThrottlingOff 1', 'Tasks\Games GPU Priority 8', 'Tasks\Games Priority 6', 'Tasks\Games Scheduling Category High', 'Tasks\Games SFIO Priority High', 'Plano de energia Alto desempenho (SCHEME_MIN)') 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 + 'Nao usa prioridade Tempo Real, nao mexe em nucleos nem' + $RS) Write-Host (' ' + $DM + 'afinidade, nao desliga o Defender, nao altera core parking.' + $RS) Write-Host '' Write-Host (' ' + $DM + 'backup .reg em ' + $RS + (fg 170 176 196) + $BkRoot + $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 $BkRoot ('Tweaks_' + $stamp) New-Item -ItemType Directory -Force -Path $bkdir | Out-Null $bkeys = @( @{ K = $K_GBAR; F = 'GameBar.reg' } @{ K = $K_GCS; F = 'GameConfigStore.reg' } @{ K = $K_GDVR; F = 'GameDVR.reg' } @{ K = $K_GDVRPOL; F = 'GameDVR_Policy.reg' } @{ K = $K_BGAPP; F = 'BackgroundApps.reg' } @{ K = $K_PTHR; F = 'PowerThrottling.reg' } @{ K = $K_GAMES; F = 'Tasks_Games.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) } } SLine 'PowerScheme.txt' Start-Sleep -Milliseconds 55 $curScheme = GetActiveScheme if ($curScheme) { Set-Content -LiteralPath (Join-Path $bkdir 'PowerScheme.txt') -Value $curScheme -Encoding ASCII SOk ('backup plano de energia atual ' + $curScheme) } else { SWarn 'nao consegui ler o plano de energia atual' } Write-Host '' Write-Host (' ' + $WH + $BLD + "2 $DOT APLICANDO / APPLYING" + $RS) Write-Host '' $tw = Tweaks $total = $tw.Count + 1 $done = 0; $fail = 0 foreach ($t in $tw) { 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++ } } SLine 'Plano de energia: Alto desempenho' Start-Sleep -Milliseconds 70 if (SetScheme 'SCHEME_MIN') { SOk 'Plano de energia: Alto desempenho'; $done++ } else { SWarn 'Alto desempenho indisponivel neste PC, plano mantido' } Write-Host '' Write-Host (Bar $total $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 } Write-Host '' Write-Host (' ' + $DM + 'backup: ' + $RS + (fg 170 176 196) + $bkdir + $RS) Write-Host (' ' + $DM + 'dica: use tambem [2] para tirar programas da inicializacao.' + $RS) Write-Host '' Write-Host (' ' + $MG + $BLD + 'curtiu? compartilha com a galera e segue @rms.tech' + $RS) try { Start-Process $LinkUrl } catch {} Pause2 } # --- restaurar / restore -------------------------------- function RunRestore { Header Write-Host (' ' + $WH + $BLD + 'RESTAURAR / RESTORE' + $RS) Write-Host '' $latest = $null if (Test-Path -LiteralPath $BkRoot) { $latest = Get-ChildItem -LiteralPath $BkRoot -Directory -Filter 'Tweaks_*' -ErrorAction SilentlyContinue | Sort-Object Name -Descending | Select-Object -First 1 } $hasStartup = (@(LoadStartupState)).Count -gt 0 if (-not $latest -and -not $hasStartup) { GBox @('Nenhum backup encontrado.', 'No backup found.') $RD Pause2; return } if ($latest) { 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) } foreach ($mk in (Get-ChildItem -LiteralPath $latest.FullName -Filter 'MISSING_*.txt' -ErrorAction SilentlyContinue)) { $origKey = (Get-Content -LiteralPath $mk.FullName -Raw).Trim() [void](RegRun delete $origKey /f) SWarn ('chave removida (nao existia antes) ' + $mk.Name) } $pf = Join-Path $latest.FullName 'PowerScheme.txt' if (Test-Path -LiteralPath $pf) { $orig = (Get-Content -LiteralPath $pf -Raw).Trim() SLine 'plano de energia original' Start-Sleep -Milliseconds 40 if ($orig -and (SetScheme $orig)) { SOk ('plano de energia restaurado ' + $orig) } else { SWarn 'nao consegui restaurar o plano de energia' } } } if ($hasStartup) { Write-Host '' Write-Host (' ' + $WH + $BLD + 'reativando programas de inicializacao' + $RS) Write-Host '' [void](RestoreStartup) } 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 = 'STARTUP'; Key = '2'; Text = "Programas de inicializacao $DOT Startup apps" } @{ Id = 'DIAG'; Key = '3'; Text = "Diagnostico de CPU $DOT CPU diagnostic" } @{ Id = 'RESTORE'; Key = '4'; Text = "Restaurar ultimo backup $DOT Restore backup" } @{ Id = 'EXIT'; Key = '5'; Text = "Sair $DOT Exit" } ) '' if ($c -eq 'APPLY') { if (Confirm) { RunApply } } elseif ($c -eq 'STARTUP') { RunStartup } elseif ($c -eq 'DIAG') { RunDiag } elseif ($c -eq 'RESTORE') { RunRestore } elseif ($c -eq 'EXIT' -or $c -eq 'BACK') { break } } } catch { Write-Host '' Write-Host (' ' + $RD + $BLD + 'ERRO INESPERADO / UNEXPECTED ERROR:' + $RS) Write-Host (' ' + $TX + $_.Exception.Message + $RS) Write-Host '' Write-Host (' ' + $DM + 'pressione qualquer tecla para fechar...' + $RS) try { [void][Console]::ReadKey($true) } catch { Read-Host | Out-Null } } finally { try { [Console]::CursorVisible = $true } catch {} Write-Host $RS Write-Host '' }