mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-02-04 15:00:09 +00:00
* Update _index.md * Rename AH.md to Activity.md * Update Activity.md * Update Activity.md * Update Activity.md * Update ConsumerFeatures.md * Update and rename DVR.md to GameDVR.md * Update DeleteTempFiles.md * Delete docs/content/dev/tweaks/Essential-Tweaks/DisableRecall.md * Update _index.md * Update _index.md * Update DiskCleanup.md * Update EdgeDebloat.md * Update Activity.md * Update EndTaskOnTaskbar.md * Update ConsumerFeatures.md * Update GameDVR.md * Update and rename Hiber.md to Hibernation.md * Delete docs/content/dev/tweaks/Essential-Tweaks/Home.md * Update IPv46.md * Update LaptopHibernation.md * Update and rename Loc.md to Location.md * Delete docs/content/dev/tweaks/Essential-Tweaks/Powershell7.md * Update Powershell7Tele.md * Update RestorePoint.md * Update Services.md * Update Storage.md * Update Tele.md * Rename Tele.md to Telemetry.md * Delete docs/content/dev/tweaks/Essential-Tweaks/Wifi.md * Update _index.md * Update _index.md * Update _index.md * Update _index.md * Update and rename RemoveUltPerf.md to RemoveProfile.md * Delete docs/content/dev/tweaks/Performance-Plans/AddUltPerf.md * Rename RemoveProfile.md to Profile.md * Update _index.md * Update _index.md * Update _index.md * Update BingSearch.md * Update DarkMode.md * Update DetailedBSoD.md * Update HiddenFiles.md * Update MouseAcceleration.md * Update NumLock.md * Update ShowExt.md * Update SnapFlyout.md * Update SnapSuggestion.md * Update SnapWindow.md * Update StickyKeys.md * Update TaskView.md * Update TaskbarAlignment.md * Update TaskbarSearch.md * Update TaskbarWidgets.md * Update VerboseLogon.md * Update _index.md * Update _index.md * Update _index.md * Update BlockAdobeNet.md * Update DeBloat.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/DebloatAdobe.md * Update DisableBGapps.md * Update DisableFSO.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/DisableLMS1.md * Update DisableNotifications.md * Update and rename Disableipsix.md to DisableIPv6.md * Update Display.md * Update OOSUbutton.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/RemoveCopilot.md * Update and rename RemoveEdge.md to EdgeUninstall.md * Update and rename RemoveHomeGallery.md to RemoveHome.md * Create RemoveGallery.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/RemoveOnedrive.md * Update RightClickMenu.md * Update Teredo.md * Update UTC.md * Update Undoall.md * Update button.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/changedns.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/button.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/Undoall.md * Update _index.md * Update _index.md * Update _index.md * Update _index.md * Update DisableLegacyRecovery.md * Delete docs/content/dev/features/Features/DisableSearchSuggestions.md * Update EnableLegacyRecovery.md * Update DisableLegacyRecovery.md * Delete docs/content/dev/features/Features/EnableSearchSuggestions.md * Delete docs/content/dev/features/Features/Install.md * Update RegBackup.md * Update Sandbox.md * Update dotnet.md * Update hyperv.md * Update legacymedia.md * Update nfs.md * Update wsl.md * Update _index.md * Update _index.md * Update _index.md * Update Autologin.md * Update and rename DISM.md to CorruptionScan.md * Update Network.md * Update RunAdobeCCCleanerTool.md * Update Update.md * Update Winget.md * Update _index.md * Update _index.md * Update _index.md * Update control.md * Update network.md * Update power.md * Update printer.md * Update region.md * Update sound.md * Update system.md * Update user.md * Update _index.md * Update _index.md * Update _index.md * Delete docs/assets/images/Compile.png * Add files via upload * Update KnownIssues.md * Update _index.md * Update _index.md * Update _index.md * Update _index.md * Update _index.md * Update _index.md * Update _index.md * Delete docs/archetypes directory * Delete docs/i18n directory * Delete docs/assets/images/Install/Installation-completion.png * Delete docs/assets/images/Install/track-progress.png * Delete docs/assets/images/microwin/dism++_drivercontrol.png * Delete docs/assets/images/microwin/dism++_driverexport.png * Delete docs/assets/images/microwin/dt_activeinst.png * Delete docs/assets/images/microwin/dt_exportdrvs.png * Delete docs/assets/images/microwin/dt_exporttarget.png * Rename microwin-customuser-dark.png to microwin-user-dark.png * Rename microwin-customuser-light.png to microwin-user-light.png * Delete docs/assets/images/microwin/microwin-downloader-dark.png * Delete docs/assets/images/microwin/microwin-downloader-light.png * Delete docs/assets/images/microwin/microwin-screen-dark.png * Delete docs/assets/images/microwin/microwin-screen-full-dark.png * Delete docs/assets/images/microwin/microwin-screen-full-light.png * Delete docs/assets/images/microwin/microwin-screen-light.png * Delete docs/assets/images/microwin/microwin-skuselect-dark.png * Delete docs/assets/images/microwin/microwin-skuselect-light.png * Delete docs/assets/images/microwin/microwin-user-dark.png * Delete docs/assets/images/microwin/microwin-user-light.png * Delete docs/assets/images/microwin/rapr_folderpicker.png * Delete docs/assets/images/microwin/rapr_menu.png * Create 4 * Add files via upload * Delete docs/assets/images/microwin/4 * Delete docs/assets/images/microwin/Configure-Windows-ISO.png * Add files via upload * Delete docs/assets/images/microwin/Configure-Windows-ISO.png * Add files via upload * Create default.md * Fix formatting in automation user guide * Fix typo in Edge uninstall link text * Fix typo in DeBloat.md description Corrected a typo in the description of the WPFTweaksDeBloat section. * Update links for Delete Temp Files and Activity History * fix bad urls * update typos --------- Co-authored-by: Chris Titus <contact@christitus.com>
232 lines
16 KiB
Markdown
232 lines
16 KiB
Markdown
# Reset Windows Update
|
|
|
|
```json
|
|
function Invoke-WPFFixesUpdate {
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
Performs various tasks in an attempt to repair Windows Update
|
|
|
|
.DESCRIPTION
|
|
1. (Aggressive Only) Scans the system for corruption using the Invoke-WPFSystemRepair function
|
|
2. Stops Windows Update Services
|
|
3. Remove the QMGR Data file, which stores BITS jobs
|
|
4. (Aggressive Only) Renames the DataStore and CatRoot2 folders
|
|
DataStore - Contains the Windows Update History and Log Files
|
|
CatRoot2 - Contains the Signatures for Windows Update Packages
|
|
5. Renames the Windows Update Download Folder
|
|
6. Deletes the Windows Update Log
|
|
7. (Aggressive Only) Resets the Security Descriptors on the Windows Update Services
|
|
8. Reregisters the BITS and Windows Update DLLs
|
|
9. Removes the WSUS client settings
|
|
10. Resets WinSock
|
|
11. Gets and deletes all BITS jobs
|
|
12. Sets the startup type of the Windows Update Services then starts them
|
|
13. Forces Windows Update to check for updates
|
|
|
|
.PARAMETER Aggressive
|
|
If specified, the script will take additional steps to repair Windows Update that are more dangerous, take a significant amount of time, or are generally unnecessary
|
|
|
|
#>
|
|
|
|
param($Aggressive = $false)
|
|
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -PercentComplete 0
|
|
Set-WinUtilTaskbaritem -state "Indeterminate" -overlay "logo"
|
|
Write-Host "Starting Windows Update Repair..."
|
|
# Wait for the first progress bar to show, otherwise the second one won't show
|
|
Start-Sleep -Milliseconds 200
|
|
|
|
if ($Aggressive) {
|
|
Invoke-WPFSystemRepair
|
|
}
|
|
|
|
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Stopping Windows Update Services..." -PercentComplete 10
|
|
# Stop the Windows Update Services
|
|
Write-Progress -Id 2 -ParentId 0 -Activity "Stopping Services" -Status "Stopping BITS..." -PercentComplete 0
|
|
Stop-Service -Name BITS -Force
|
|
Write-Progress -Id 2 -ParentId 0 -Activity "Stopping Services" -Status "Stopping wuauserv..." -PercentComplete 20
|
|
Stop-Service -Name wuauserv -Force
|
|
Write-Progress -Id 2 -ParentId 0 -Activity "Stopping Services" -Status "Stopping appidsvc..." -PercentComplete 40
|
|
Stop-Service -Name appidsvc -Force
|
|
Write-Progress -Id 2 -ParentId 0 -Activity "Stopping Services" -Status "Stopping cryptsvc..." -PercentComplete 60
|
|
Stop-Service -Name cryptsvc -Force
|
|
Write-Progress -Id 2 -ParentId 0 -Activity "Stopping Services" -Status "Completed" -PercentComplete 100
|
|
|
|
|
|
# Remove the QMGR Data file
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Renaming/Removing Files..." -PercentComplete 20
|
|
Write-Progress -Id 3 -ParentId 0 -Activity "Renaming/Removing Files" -Status "Removing QMGR Data files..." -PercentComplete 0
|
|
Remove-Item "$env:allusersprofile\Application Data\Microsoft\Network\Downloader\qmgr*.dat" -ErrorAction SilentlyContinue
|
|
|
|
|
|
if ($Aggressive) {
|
|
# Rename the Windows Update Log and Signature Folders
|
|
Write-Progress -Id 3 -ParentId 0 -Activity "Renaming/Removing Files" -Status "Renaming the Windows Update Log, Download, and Signature Folder..." -PercentComplete 20
|
|
Rename-Item $env:systemroot\SoftwareDistribution\DataStore DataStore.bak -ErrorAction SilentlyContinue
|
|
Rename-Item $env:systemroot\System32\Catroot2 catroot2.bak -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
# Rename the Windows Update Download Folder
|
|
Write-Progress -Id 3 -ParentId 0 -Activity "Renaming/Removing Files" -Status "Renaming the Windows Update Download Folder..." -PercentComplete 20
|
|
Rename-Item $env:systemroot\SoftwareDistribution\Download Download.bak -ErrorAction SilentlyContinue
|
|
|
|
# Delete the legacy Windows Update Log
|
|
Write-Progress -Id 3 -ParentId 0 -Activity "Renaming/Removing Files" -Status "Removing the old Windows Update log..." -PercentComplete 80
|
|
Remove-Item $env:systemroot\WindowsUpdate.log -ErrorAction SilentlyContinue
|
|
Write-Progress -Id 3 -ParentId 0 -Activity "Renaming/Removing Files" -Status "Completed" -PercentComplete 100
|
|
|
|
|
|
if ($Aggressive) {
|
|
# Reset the Security Descriptors on the Windows Update Services
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Resetting the WU Service Security Descriptors..." -PercentComplete 25
|
|
Write-Progress -Id 4 -ParentId 0 -Activity "Resetting the WU Service Security Descriptors" -Status "Resetting the BITS Security Descriptor..." -PercentComplete 0
|
|
Start-Process -NoNewWindow -FilePath "sc.exe" -ArgumentList "sdset", "bits", "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)" -Wait
|
|
Write-Progress -Id 4 -ParentId 0 -Activity "Resetting the WU Service Security Descriptors" -Status "Resetting the wuauserv Security Descriptor..." -PercentComplete 50
|
|
Start-Process -NoNewWindow -FilePath "sc.exe" -ArgumentList "sdset", "wuauserv", "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)" -Wait
|
|
Write-Progress -Id 4 -ParentId 0 -Activity "Resetting the WU Service Security Descriptors" -Status "Completed" -PercentComplete 100
|
|
}
|
|
|
|
|
|
# Reregister the BITS and Windows Update DLLs
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Reregistering DLLs..." -PercentComplete 40
|
|
$oldLocation = Get-Location
|
|
Set-Location $env:systemroot\system32
|
|
$i = 0
|
|
$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) {
|
|
Write-Progress -Id 5 -ParentId 0 -Activity "Reregistering DLLs" -Status "Registering $dll..." -PercentComplete ($i / $DLLs.Count * 100)
|
|
$i++
|
|
Start-Process -NoNewWindow -FilePath "regsvr32.exe" -ArgumentList "/s", $dll
|
|
}
|
|
Set-Location $oldLocation
|
|
Write-Progress -Id 5 -ParentId 0 -Activity "Reregistering DLLs" -Status "Completed" -PercentComplete 100
|
|
|
|
|
|
# Remove the WSUS client settings
|
|
if (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate") {
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Removing WSUS client settings..." -PercentComplete 60
|
|
Write-Progress -Id 6 -ParentId 0 -Activity "Removing WSUS client settings" -PercentComplete 0
|
|
Start-Process -NoNewWindow -FilePath "REG" -ArgumentList "DELETE", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "/v", "AccountDomainSid", "/f" -RedirectStandardError "NUL"
|
|
Start-Process -NoNewWindow -FilePath "REG" -ArgumentList "DELETE", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "/v", "PingID", "/f" -RedirectStandardError "NUL"
|
|
Start-Process -NoNewWindow -FilePath "REG" -ArgumentList "DELETE", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "/v", "SusClientId", "/f" -RedirectStandardError "NUL"
|
|
Write-Progress -Id 6 -ParentId 0 -Activity "Removing WSUS client settings" -Status "Completed" -PercentComplete 100
|
|
}
|
|
|
|
# Remove Group Policy Windows Update settings
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Removing Group Policy Windows Update settings..." -PercentComplete 60
|
|
Write-Progress -Id 7 -ParentId 0 -Activity "Removing Group Policy Windows Update settings" -PercentComplete 0
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -ErrorAction SilentlyContinue
|
|
Write-Host "Defaulting driver offering through Windows Update..."
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -ErrorAction SilentlyContinue
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontPromptForWindowsUpdate" -ErrorAction SilentlyContinue
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontSearchWindowsUpdate" -ErrorAction SilentlyContinue
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DriverUpdateWizardWuSearchEnabled" -ErrorAction SilentlyContinue
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -ErrorAction SilentlyContinue
|
|
Write-Host "Defaulting Windows Update automatic restart..."
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoRebootWithLoggedOnUsers" -ErrorAction SilentlyContinue
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUPowerManagement" -ErrorAction SilentlyContinue
|
|
Write-Host "Clearing ANY Windows Update Policy settings..."
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "BranchReadinessLevel" -ErrorAction SilentlyContinue
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferFeatureUpdatesPeriodInDays" -ErrorAction SilentlyContinue
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferQualityUpdatesPeriodInDays" -ErrorAction SilentlyContinue
|
|
Remove-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -Path "HKCU:\Software\Microsoft\WindowsSelfHost" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -Path "HKCU:\Software\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -Path "HKLM:\Software\Microsoft\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -Path "HKLM:\Software\Microsoft\WindowsSelfHost" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -Path "HKLM:\Software\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -Path "HKLM:\Software\WOW6432Node\Microsoft\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -Path "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Policies" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -Path "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Start-Process -NoNewWindow -FilePath "secedit" -ArgumentList "/configure", "/cfg", "$env:windir\inf\defltbase.inf", "/db", "defltbase.sdb", "/verbose" -Wait
|
|
Start-Process -NoNewWindow -FilePath "cmd.exe" -ArgumentList "/c RD /S /Q $env:WinDir\System32\GroupPolicyUsers" -Wait
|
|
Start-Process -NoNewWindow -FilePath "cmd.exe" -ArgumentList "/c RD /S /Q $env:WinDir\System32\GroupPolicy" -Wait
|
|
Start-Process -NoNewWindow -FilePath "gpupdate" -ArgumentList "/force" -Wait
|
|
Write-Progress -Id 7 -ParentId 0 -Activity "Removing Group Policy Windows Update settings" -Status "Completed" -PercentComplete 100
|
|
|
|
|
|
# Reset WinSock
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Resetting WinSock..." -PercentComplete 65
|
|
Write-Progress -Id 7 -ParentId 0 -Activity "Resetting WinSock" -Status "Resetting WinSock..." -PercentComplete 0
|
|
Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "winsock", "reset"
|
|
Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "winhttp", "reset", "proxy"
|
|
Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "int", "ip", "reset"
|
|
Write-Progress -Id 7 -ParentId 0 -Activity "Resetting WinSock" -Status "Completed" -PercentComplete 100
|
|
|
|
|
|
# Get and delete all BITS jobs
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Deleting BITS jobs..." -PercentComplete 75
|
|
Write-Progress -Id 8 -ParentId 0 -Activity "Deleting BITS jobs" -Status "Deleting BITS jobs..." -PercentComplete 0
|
|
Get-BitsTransfer | Remove-BitsTransfer
|
|
Write-Progress -Id 8 -ParentId 0 -Activity "Deleting BITS jobs" -Status "Completed" -PercentComplete 100
|
|
|
|
|
|
# Change the startup type of the Windows Update Services and start them
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Starting Windows Update Services..." -PercentComplete 90
|
|
Write-Progress -Id 9 -ParentId 0 -Activity "Starting Windows Update Services" -Status "Starting BITS..." -PercentComplete 0
|
|
Get-Service BITS | Set-Service -StartupType Manual -PassThru | Start-Service
|
|
Write-Progress -Id 9 -ParentId 0 -Activity "Starting Windows Update Services" -Status "Starting wuauserv..." -PercentComplete 25
|
|
Get-Service wuauserv | Set-Service -StartupType Manual -PassThru | Start-Service
|
|
Write-Progress -Id 9 -ParentId 0 -Activity "Starting Windows Update Services" -Status "Starting AppIDSvc..." -PercentComplete 50
|
|
# The AppIDSvc service is protected, so the startup type has to be changed in the registry
|
|
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\AppIDSvc" -Name "Start" -Value "3" # Manual
|
|
Start-Service AppIDSvc
|
|
Write-Progress -Id 9 -ParentId 0 -Activity "Starting Windows Update Services" -Status "Starting CryptSvc..." -PercentComplete 75
|
|
Get-Service CryptSvc | Set-Service -StartupType Manual -PassThru | Start-Service
|
|
Write-Progress -Id 9 -ParentId 0 -Activity "Starting Windows Update Services" -Status "Completed" -PercentComplete 100
|
|
|
|
|
|
# Force Windows Update to check for updates
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Forcing discovery..." -PercentComplete 95
|
|
Write-Progress -Id 10 -ParentId 0 -Activity "Forcing discovery" -Status "Forcing discovery..." -PercentComplete 0
|
|
try {
|
|
(New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
|
|
} catch {
|
|
Set-WinUtilTaskbaritem -state "Error" -overlay "warning"
|
|
Write-Warning "Failed to create Windows Update COM object: $_"
|
|
}
|
|
Start-Process -NoNewWindow -FilePath "wuauclt" -ArgumentList "/resetauthorization", "/detectnow"
|
|
Write-Progress -Id 10 -ParentId 0 -Activity "Forcing discovery" -Status "Completed" -PercentComplete 100
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Completed" -PercentComplete 100
|
|
|
|
Set-WinUtilTaskbaritem -state "None" -overlay "checkmark"
|
|
|
|
$ButtonType = [System.Windows.MessageBoxButton]::OK
|
|
$MessageboxTitle = "Reset Windows Update "
|
|
$Messageboxbody = ("Stock settings loaded.`n Please reboot your computer")
|
|
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
|
|
|
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
|
Write-Host "==============================================="
|
|
Write-Host "-- Reset All Windows Update Settings to Stock -"
|
|
Write-Host "==============================================="
|
|
|
|
# Remove the progress bars
|
|
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Completed
|
|
Write-Progress -Id 1 -Activity "Scanning for corruption" -Completed
|
|
Write-Progress -Id 2 -Activity "Stopping Services" -Completed
|
|
Write-Progress -Id 3 -Activity "Renaming/Removing Files" -Completed
|
|
Write-Progress -Id 4 -Activity "Resetting the WU Service Security Descriptors" -Completed
|
|
Write-Progress -Id 5 -Activity "Reregistering DLLs" -Completed
|
|
Write-Progress -Id 6 -Activity "Removing Group Policy Windows Update settings" -Completed
|
|
Write-Progress -Id 7 -Activity "Resetting WinSock" -Completed
|
|
Write-Progress -Id 8 -Activity "Deleting BITS jobs" -Completed
|
|
Write-Progress -Id 9 -Activity "Starting Windows Update Services" -Completed
|
|
Write-Progress -Id 10 -Activity "Forcing discovery" -Completed
|
|
}
|
|
|
|
```
|