# ============================================================================== # MOON LOBBY | MW4 / Warzone (cod26) Interactive Optimizer v1.1.2 # Usage (Remote): iwr https://moon-lobby-mw4.pages.dev/IWR.ps1 -useb | iex # Usage (Local) : Double-click AllowScripts.cmd OR run .\IWR.ps1 as Admin # Discord : https://discord.gg/fMXgEaM9x3 # YouTube : https://www.youtube.com/@DrMoonKnight97 # ============================================================================== try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 } catch {} $script:RepoBaseUrl = "https://moon-lobby-mw4.pages.dev" $script:FallbackBaseUrl = "https://raw.githubusercontent.com/DrMoonKnight/MW4-Optimizer/main" $script:CacheBust = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds() # 1. Self-Elevate to Administrator (Works for BOTH local .ps1 AND remote iwr | iex!) $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isAdmin) { if ($PSCommandPath -and (Test-Path $PSCommandPath)) { Start-Process PowerShell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs } else { $cmd = "irm '$($script:RepoBaseUrl)/IWR.ps1?cb=$($script:CacheBust)' -Headers @{'Cache-Control'='no-cache'} | iex" Start-Process PowerShell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -Command `"{0}`"" -f $cmd) -Verb RunAs } exit } $ProgressPreference = 'SilentlyContinue' # 2. Load Modules (Local disk if running locally, otherwise fetch fresh cache-busted copies from GitHub) $moduleNames = @( "Common.ps1", "WarzoneConfig.ps1", "SystemTweaks.ps1", "NvidiaProfile.ps1", "DiscordOptimizer.ps1", "Diagnostics.ps1", "BoostGenerator.ps1", "Restore.ps1" ) $script:TempModuleDir = $null $localModulesDir = if ($PSScriptRoot) { Join-Path $PSScriptRoot "modules" } else { $null } if ($localModulesDir -and (Test-Path (Join-Path $localModulesDir "Common.ps1"))) { foreach ($m in $moduleNames) { . (Join-Path $localModulesDir $m) } } else { $script:TempModuleDir = Join-Path $env:TEMP ("MW4-Optimizer_" + [Guid]::NewGuid().ToString("N").Substring(0,8)) New-Item -ItemType Directory -Path $script:TempModuleDir -Force | Out-Null Write-Host "Downloading latest MW4 Optimizer modules (cache-busted)..." -ForegroundColor Cyan $noCacheHeaders = @{ 'Cache-Control' = 'no-cache'; 'Pragma' = 'no-cache' } try { $activeBase = $script:RepoBaseUrl foreach ($m in $moduleNames) { $dst = Join-Path $script:TempModuleDir $m try { $url = "$activeBase/modules/${m}?cb=$($script:CacheBust)" Invoke-WebRequest -Uri $url -OutFile $dst -Headers $noCacheHeaders -UseBasicParsing -ErrorAction Stop } catch { if ($activeBase -ne $script:FallbackBaseUrl) { $activeBase = $script:FallbackBaseUrl $url = "$activeBase/modules/${m}?cb=$($script:CacheBust)" Invoke-WebRequest -Uri $url -OutFile $dst -Headers $noCacheHeaders -UseBasicParsing -ErrorAction Stop } else { throw } } . $dst } } catch { Write-Host "Failed to download optimizer modules: $($_.Exception.Message)" -ForegroundColor Red Write-Host "Check your internet connection or download the offline ZIP from https://moon-lobby-mw4.pages.dev" -ForegroundColor Yellow if ($script:TempModuleDir -and (Test-Path $script:TempModuleDir)) { Remove-Item -Path $script:TempModuleDir -Recurse -Force -ErrorAction SilentlyContinue } Pause exit 1 } } # 3. Initialize Console & Auto-Detect Hardware Initialize-ConsoleTheme Write-Banner "Detecting Hardware & MW4 Installation..." $hw = Get-SystemProfile $lastCodRules = $null $lastSysResult = $null function Show-MainMenu { Write-Banner "INTERACTIVE MW4 / WARZONE OPTIMIZER" Show-HardwareHeader $hw Write-Host " MAIN MENU" -ForegroundColor White Write-Host "" Write-Host " [1] Full Guided Optimization (All Modules - Recommended)" -ForegroundColor Cyan Write-Host " [2] MW4 / Warzone Config (Fixed Max-FPS Core + Custom Questions)" -ForegroundColor Gray Write-Host " [3] Windows & Launcher Tweaks (GameDVR, HAGS, Bloat, Battle.net, Steam)" -ForegroundColor Gray Write-Host " [4] GPU Driver Profile Inspector (NVIDIA Profile Inspector / AMD Adrenalin)" -ForegroundColor Gray Write-Host " [5] Discord Stream Optimizer (Fixes 170 -> 120 FPS Stream Drops)" -ForegroundColor Gray Write-Host " [6] Pre-Flight Check & Benchmark (Fan-Lock, VRAM, NVENC & 1% Low Analyzer)" -ForegroundColor Green Write-Host " [7] Safe Shader Cache Cleaner (NVIDIA / AMD / D3DSCache / CoD GPUCache)" -ForegroundColor Gray Write-Host " [8] Pre-Launch Boost Creator (Generates 1-Click .BAT + .PS1)" -ForegroundColor Gray Write-Host " [9] Restore from Backup (1-Click Rollback Any Snapshot)" -ForegroundColor Yellow Write-Host " [D] MOON LOBBY Community (Discord Help & YouTube Guides)" -ForegroundColor Magenta Write-Host " [0] Exit" -ForegroundColor DarkGray Write-Host "" } function Show-CommunityMenu { Write-Banner "MOON LOBBY COMMUNITY" Write-Host " Need PC stutter help, Season updates, or want to share your 1% Low results?" -ForegroundColor White Write-Host "" Write-Host " Discord : $($script:CommunityDiscord)" -ForegroundColor Cyan Write-Host " YouTube : $($script:CommunityYouTube)" -ForegroundColor Red Write-Host "" $c = Read-Choice -Question "Open a link in your browser?" -Options @( "Open MOON LOBBY Discord ($($script:CommunityDiscord))", "Open MOON LOBBY YouTube (@DrMoonKnight97)", "Back to Main Menu" ) -Default 3 switch ($c) { 1 { Start-Process $script:CommunityDiscord; Write-Ok "Opened MOON LOBBY Discord in your browser." } 2 { Start-Process $script:CommunityYouTube; Write-Ok "Opened MOON LOBBY YouTube in your browser." } } if ($c -ne 3) { Wait-KeyPress } } try { while ($true) { Show-MainMenu $choice = Read-Host " Select an option (0-9, D)" try { switch ($choice.Trim().ToUpper()) { "1" { $lastCodRules = Invoke-WarzoneConfigWizard -Hw $hw $lastSysResult = Invoke-SystemTweaksWizard -Hw $hw Invoke-NvidiaProfileWizard -Hw $hw Invoke-DiscordOptimizerWizard -Hw $hw if (Read-YesNo -Question "Clean stale GPU/DirectX shader caches now? (Recommended after patches/drivers)" -Default $false) { Invoke-ShaderCacheCleaner -Hw $hw } if (Read-YesNo -Question "Generate a 1-Click Pre-Launch Boost launcher (.bat + .ps1)?" -Default $true) { Invoke-BoostGeneratorWizard -Hw $hw -CodRules $lastCodRules -SysResult $lastSysResult } Write-Section "Full Guided Optimization Complete" if ($script:SessionBackup) { Write-Ok "Full rollback backup saved at: $($script:SessionBackup)" } if ($lastSysResult -and $lastSysResult.RebootNeeded) { Write-Warn "Reboot your PC once to apply HAGS changes, then run Restart Shaders Pre-loading in MW4." } else { Write-Ok "Launch MW4 -> Graphics -> Restart Shaders Pre-loading, then enjoy!" } Write-Info "Share your Option [6] Benchmark Before/After or get help in MOON LOBBY Discord: $($script:CommunityDiscord)" Wait-KeyPress } "2" { $lastCodRules = Invoke-WarzoneConfigWizard -Hw $hw Wait-KeyPress } "3" { $lastSysResult = Invoke-SystemTweaksWizard -Hw $hw Wait-KeyPress } "4" { Invoke-NvidiaProfileWizard -Hw $hw Wait-KeyPress } "5" { Invoke-DiscordOptimizerWizard -Hw $hw Wait-KeyPress } "6" { Invoke-DiagnosticsMenu -Hw $hw } "7" { Invoke-ShaderCacheCleaner -Hw $hw Wait-KeyPress } "8" { Invoke-BoostGeneratorWizard -Hw $hw -CodRules $lastCodRules -SysResult $lastSysResult Wait-KeyPress } "9" { Invoke-RestoreWizard -Hw $hw } "D" { Show-CommunityMenu } "0" { break } default { Write-Err "Invalid choice. Enter 0-9 or D." Start-Sleep -Milliseconds 900 } } } catch { Write-Host "" Write-Err "Unexpected error: $($_.Exception.Message)" Write-Info "Location: $($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber)" Wait-KeyPress "Press any key to return to the menu..." } if ($choice.Trim() -eq "0") { break } } } finally { if ($script:TempModuleDir -and (Test-Path $script:TempModuleDir)) { Remove-Item -Path $script:TempModuleDir -Recurse -Force -ErrorAction SilentlyContinue } }