# PCS Toolkit - Windows Update Fix # Resets Windows Update components $timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss" $logFile = "$env:USERPROFILE\Desktop\WindowsUpdateFix_$timestamp.log" function Log($msg) { $line = "$(Get-Date -Format 'HH:mm:ss') - $msg" Write-Host $line Add-Content $logFile $line } Log "========================================" Log " PCS Toolkit - Windows Update Fix" Log "========================================" Log "Computer: $env:COMPUTERNAME" Log "" $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isAdmin) { Log "ERROR: This script must be run as Administrator!" Read-Host "Press Enter to exit" exit } Log "Step 1: Stopping Windows Update services..." $services = @('wuauserv', 'cryptSvc', 'bits', 'msiserver') foreach ($svc in $services) { Stop-Service -Name $svc -Force -EA SilentlyContinue Log " Stopped: $svc" } Log "Step 2: Renaming SoftwareDistribution folder..." if (Test-Path "$env:SystemRoot\SoftwareDistribution") { Rename-Item "$env:SystemRoot\SoftwareDistribution" "SoftwareDistribution.old.$timestamp" -Force -EA SilentlyContinue Log " Renamed to SoftwareDistribution.old.$timestamp" } Log "Step 3: Renaming Catroot2 folder..." if (Test-Path "$env:SystemRoot\System32\catroot2") { Rename-Item "$env:SystemRoot\System32\catroot2" "catroot2.old.$timestamp" -Force -EA SilentlyContinue Log " Renamed to catroot2.old.$timestamp" } Log "Step 4: Re-registering Windows Update DLLs..." $dlls = @( 'atl.dll', 'urlmon.dll', 'mshtml.dll', 'shdocvw.dll', 'browseui.dll', 'jscript.dll', 'vbscript.dll', 'scrrun.dll', 'msxml.dll', 'msxml3.dll', 'msxml6.dll', 'actxprxy.dll', 'softpub.dll', 'wintrust.dll', 'dssenh.dll', 'rsaenh.dll', 'gpkcsp.dll', 'sccbase.dll', 'slbcsp.dll', 'cryptdlg.dll', 'oleaut32.dll', 'ole32.dll', 'shell32.dll', 'initpki.dll', 'wuapi.dll', 'wuaueng.dll', 'wuaueng1.dll', 'wucltui.dll', 'wups.dll', 'wups2.dll', 'wuweb.dll', 'qmgr.dll', 'qmgrprxy.dll', 'wucltux.dll', 'muweb.dll', 'wuwebv.dll' ) foreach ($dll in $dlls) { regsvr32.exe /s $dll 2>$null } Log " Registered $($dlls.Count) DLLs" Log "Step 5: Resetting Winsock..." netsh winsock reset 2>$null Log " Done" Log "Step 6: Starting Windows Update services..." foreach ($svc in $services) { Start-Service -Name $svc -EA SilentlyContinue Log " Started: $svc" } Log "" Log "========================================" Log "WINDOWS UPDATE FIX COMPLETE" Log "========================================" Log "" Log "Reboot recommended. Then run Windows Update." explorer.exe "/select,$logFile" Read-Host "Press Enter to exit"