Last active
October 20, 2025 00:13
-
-
Save LinkPhoenix/69ab3d36e4c5e675024962c6ad0e2d8c to your computer and use it in GitHub Desktop.
PowerShell script to fix Windows Store installation errors caused by privacy tools and restore normal functionality.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Fix Windows Store errors and restore functionality to resolve installation or update issues. | |
| .DESCRIPTION | |
| This script repairs Microsoft Store and related system services by reverting privacy modifications | |
| made by tools such as privacy-script.bat from privacy.sexy. It addresses the common error | |
| 0x80004002 (E_NOINTERFACE) and other issues that prevent the Microsoft Store from installing or updating apps. | |
| The script re-enables essential services like Windows Update and Delivery Optimization, | |
| restores registry values, repairs connectivity checks, clears caches, and resets Store apps. | |
| Administrator privileges are required. | |
| .PARAMETER Force | |
| Runs the script immediately without user confirmation. | |
| .PARAMETER Silent | |
| Suppresses interactive prompts and pauses for automation. | |
| .EXAMPLE | |
| .\WindowsStore-Fix.ps1 | |
| Launches the repair process interactively, restoring Windows Store functionality. | |
| .EXAMPLE | |
| .\WindowsStore-Fix.ps1 -Force -Silent | |
| Executes all fixes unattended, recommended for automated deployments. | |
| .NOTES | |
| Created: 2025-10-20 | |
| Version: 1.0 | |
| Tested on: Windows 11 Pro 25H2 | |
| #> | |
| param( | |
| [switch]$Force, | |
| [switch]$Silent | |
| ) | |
| # Function to display colored output | |
| function Write-ColorOutput { | |
| param( | |
| [string]$Message, | |
| [string]$Color = "White" | |
| ) | |
| Write-Host $Message -ForegroundColor $Color | |
| } | |
| # Function to display step information | |
| function Show-Step { | |
| param( | |
| [string]$Step, | |
| [string]$Description | |
| ) | |
| Write-ColorOutput "`n[STEP $Step] $Description" "Cyan" | |
| } | |
| # Function to check if running as administrator | |
| function Test-Administrator { | |
| $currentUser = [Security.Principal.WindowsIdentity]::GetCurrent() | |
| $principal = New-Object Security.Principal.WindowsPrincipal($currentUser) | |
| return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | |
| } | |
| # Function to restart script as administrator | |
| function Restart-AsAdministrator { | |
| Write-ColorOutput "This script requires administrator privileges." "Yellow" | |
| Write-ColorOutput "Restarting with elevated privileges..." "Yellow" | |
| $scriptPath = $MyInvocation.MyCommand.Path | |
| Start-Process PowerShell -ArgumentList "-ExecutionPolicy Bypass -File `"$scriptPath`"" -Verb RunAs | |
| exit | |
| } | |
| # Function to get user confirmation | |
| function Get-UserConfirmation { | |
| param( | |
| [string]$Message, | |
| [string]$Default = "Y" | |
| ) | |
| if ($Silent) { return $true } | |
| $choices = @("Y", "N") | |
| do { | |
| $response = Read-Host "$Message (Y/N) [$Default]" | |
| if ([string]::IsNullOrEmpty($response)) { | |
| $response = $Default | |
| } | |
| $response = $response.ToUpper() | |
| } while ($choices -notcontains $response) | |
| return $response -eq "Y" | |
| } | |
| # Function to check service status with detailed information | |
| function Test-ServiceStatus { | |
| param( | |
| [string]$ServiceName, | |
| [string]$DisplayName | |
| ) | |
| try { | |
| $service = Get-Service -Name $ServiceName -ErrorAction Stop | |
| $status = $service.Status | |
| $startType = $service.StartType | |
| Write-ColorOutput " ${DisplayName}:" "White" | |
| Write-ColorOutput " Status: $status" $(if ($status -eq "Running") { "Green" } else { "Red" }) | |
| Write-ColorOutput " Start Type: $startType" $(if ($startType -eq "Automatic") { "Green" } else { "Yellow" }) | |
| Write-ColorOutput " Service Name: $ServiceName" "Gray" | |
| return @{ | |
| Status = $status | |
| StartType = $startType | |
| Service = $service | |
| } | |
| } | |
| catch { | |
| Write-ColorOutput " ${DisplayName}: Not found or not accessible" "Red" | |
| Write-ColorOutput " Service Name: $ServiceName" "Gray" | |
| return $null | |
| } | |
| } | |
| # Function to enable and start service | |
| function Enable-Service { | |
| param( | |
| [string]$ServiceName, | |
| [string]$DisplayName | |
| ) | |
| try { | |
| $service = Get-Service -Name $ServiceName -ErrorAction Stop | |
| Write-ColorOutput " Current state before fix:" "Yellow" | |
| Write-ColorOutput " Status: $($service.Status)" $(if ($service.Status -eq "Running") { "Green" } else { "Red" }) | |
| Write-ColorOutput " Start Type: $($service.StartType)" $(if ($service.StartType -eq "Automatic") { "Green" } else { "Yellow" }) | |
| # Set startup type to Automatic | |
| Set-Service -Name $ServiceName -StartupType Automatic -ErrorAction Stop | |
| Write-ColorOutput " ✓ Startup type set to Automatic" "Green" | |
| # Start service if not running | |
| if ($service.Status -ne "Running") { | |
| Start-Service -Name $ServiceName -ErrorAction Stop | |
| Write-ColorOutput " ✓ Service started successfully" "Green" | |
| } else { | |
| Write-ColorOutput " ✓ Service is already running" "Green" | |
| } | |
| # Verify the fix | |
| $updatedService = Get-Service -Name $ServiceName -ErrorAction Stop | |
| Write-ColorOutput " Final state after fix:" "Yellow" | |
| Write-ColorOutput " Status: $($updatedService.Status)" $(if ($updatedService.Status -eq "Running") { "Green" } else { "Red" }) | |
| Write-ColorOutput " Start Type: $($updatedService.StartType)" $(if ($updatedService.StartType -eq "Automatic") { "Green" } else { "Yellow" }) | |
| return $true | |
| } | |
| catch { | |
| Write-ColorOutput " ✗ Failed to enable service: $($_.Exception.Message)" "Red" | |
| return $false | |
| } | |
| } | |
| # Function to check and fix registry values | |
| function Test-RegistryValue { | |
| param( | |
| [string]$RegistryPath, | |
| [string]$ValueName, | |
| [string]$ExpectedValue, | |
| [string]$ValueType = "DWORD", | |
| [string]$Description | |
| ) | |
| Write-ColorOutput " ${Description}:" "White" | |
| Write-ColorOutput " Registry Path: $RegistryPath" "Gray" | |
| Write-ColorOutput " Value Name: $ValueName" "Gray" | |
| try { | |
| $currentValue = Get-ItemProperty -Path $RegistryPath -Name $ValueName -ErrorAction Stop | Select-Object -ExpandProperty $ValueName | |
| Write-ColorOutput " Current Value: $currentValue" $(if ($currentValue -eq $ExpectedValue) { "Green" } else { "Red" }) | |
| Write-ColorOutput " Expected Value: $ExpectedValue" "Yellow" | |
| if ($currentValue -ne $ExpectedValue) { | |
| Write-ColorOutput " Fixing registry value..." "Yellow" | |
| Set-ItemProperty -Path $RegistryPath -Name $ValueName -Value $ExpectedValue -Type $ValueType -ErrorAction Stop | |
| Write-ColorOutput " ✓ Registry value updated successfully" "Green" | |
| # Verify the fix | |
| $newValue = Get-ItemProperty -Path $RegistryPath -Name $ValueName -ErrorAction Stop | Select-Object -ExpandProperty $ValueName | |
| Write-ColorOutput " Final Value: $newValue" $(if ($newValue -eq $ExpectedValue) { "Green" } else { "Red" }) | |
| return $true | |
| } else { | |
| Write-ColorOutput " ✓ Registry value is already correct" "Green" | |
| return $true | |
| } | |
| } | |
| catch { | |
| Write-ColorOutput " ✗ Failed to check/fix registry value: $($_.Exception.Message)" "Red" | |
| return $false | |
| } | |
| } | |
| # Function to remove hosts file entries | |
| function Remove-HostsEntries { | |
| param( | |
| [string[]]$Domains | |
| ) | |
| $hostsFile = "$env:SYSTEMROOT\System32\drivers\etc\hosts" | |
| Write-ColorOutput " Hosts File Analysis:" "White" | |
| Write-ColorOutput " File Path: $hostsFile" "Gray" | |
| if (-not (Test-Path $hostsFile)) { | |
| Write-ColorOutput " Hosts file not found" "Yellow" | |
| return $false | |
| } | |
| try { | |
| $content = Get-Content $hostsFile -Encoding UTF8 | |
| $originalCount = $content.Count | |
| Write-ColorOutput " Total lines in hosts file: $originalCount" "Gray" | |
| # Check for blocked domains | |
| $blockedDomains = @() | |
| foreach ($domain in $Domains) { | |
| $blockedLines = $content | Where-Object { $_ -match [regex]::Escape($domain) } | |
| if ($blockedLines) { | |
| $blockedDomains += $domain | |
| Write-ColorOutput " Found blocked domain: $domain" "Red" | |
| } else { | |
| Write-ColorOutput " Domain not blocked: $domain" "Green" | |
| } | |
| } | |
| if ($blockedDomains.Count -gt 0) { | |
| Write-ColorOutput " Removing blocked domains..." "Yellow" | |
| foreach ($domain in $Domains) { | |
| $content = $content | Where-Object { $_ -notmatch [regex]::Escape($domain) } | |
| } | |
| $newCount = $content.Count | |
| $removedCount = $originalCount - $newCount | |
| if ($removedCount -gt 0) { | |
| $content | Set-Content $hostsFile -Encoding UTF8 | |
| Write-ColorOutput " ✓ Removed $removedCount entries from hosts file" "Green" | |
| Write-ColorOutput " Final line count: $newCount" "Gray" | |
| return $true | |
| } | |
| } else { | |
| Write-ColorOutput " ✓ No blocked domains found in hosts file" "Green" | |
| return $true | |
| } | |
| } | |
| catch { | |
| Write-ColorOutput " ✗ Failed to modify hosts file: $($_.Exception.Message)" "Red" | |
| return $false | |
| } | |
| } | |
| # Function to restore NCSI app | |
| function Restore-NCSIApp { | |
| try { | |
| Write-ColorOutput " NCSI App Status:" "White" | |
| # Check if NCSI app is already installed | |
| $ncsiApp = Get-AppxPackage -Name "NcsiUwpApp" -AllUsers -ErrorAction SilentlyContinue | |
| if ($ncsiApp) { | |
| Write-ColorOutput " ✓ NCSI app is already installed" "Green" | |
| Write-ColorOutput " Package Name: $($ncsiApp.Name)" "Gray" | |
| Write-ColorOutput " Version: $($ncsiApp.Version)" "Gray" | |
| return $true | |
| } else { | |
| Write-ColorOutput " ✗ NCSI app not found" "Red" | |
| } | |
| # Try to restore from Windows image | |
| Write-ColorOutput " Attempting to restore NCSI app..." "Yellow" | |
| # Remove from EndOfLife if present | |
| $userSid = (New-Object System.Security.Principal.WindowsIdentity([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)).User.Value | |
| $endOfLifePath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife\$userSid\NcsiUwpApp_8wekyb3d8bbwe" | |
| Write-ColorOutput " Checking EndOfLife registry: $endOfLifePath" "Gray" | |
| if (Test-Path $endOfLifePath) { | |
| Remove-Item $endOfLifePath -Force -ErrorAction SilentlyContinue | |
| Write-ColorOutput " ✓ Removed from EndOfLife list" "Green" | |
| } else { | |
| Write-ColorOutput " ✓ Not in EndOfLife list" "Green" | |
| } | |
| # Remove from Deprovisioned if present | |
| $deprovisionedPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\NcsiUwpApp_8wekyb3d8bbwe" | |
| Write-ColorOutput " Checking Deprovisioned registry: $deprovisionedPath" "Gray" | |
| if (Test-Path $deprovisionedPath) { | |
| Remove-Item $deprovisionedPath -Force -ErrorAction SilentlyContinue | |
| Write-ColorOutput " ✓ Removed from Deprovisioned list" "Green" | |
| } else { | |
| Write-ColorOutput " ✓ Not in Deprovisioned list" "Green" | |
| } | |
| # Try to reinstall the app | |
| Write-ColorOutput " Attempting to reinstall NCSI app..." "Yellow" | |
| $result = Get-AppxPackage -AllUsers -Name "NcsiUwpApp" | Add-AppxPackage -RegisterByFamilyName -MainPackage -ErrorAction SilentlyContinue | |
| if ($result) { | |
| Write-ColorOutput " ✓ NCSI app restored successfully" "Green" | |
| return $true | |
| } else { | |
| Write-ColorOutput " ⚠ NCSI app could not be restored automatically" "Yellow" | |
| Write-ColorOutput " This is not critical for Store functionality" "Yellow" | |
| return $false | |
| } | |
| } | |
| catch { | |
| Write-ColorOutput " ✗ Failed to restore NCSI app: $($_.Exception.Message)" "Red" | |
| return $false | |
| } | |
| } | |
| # Function to clear Store cache | |
| function Clear-StoreCache { | |
| try { | |
| $storeCachePaths = @( | |
| "$env:LOCALAPPDATA\Packages\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalCache", | |
| "$env:LOCALAPPDATA\Packages\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState" | |
| ) | |
| Write-ColorOutput " Store Cache Analysis:" "White" | |
| $clearedCount = 0 | |
| foreach ($path in $storeCachePaths) { | |
| Write-ColorOutput " Checking: $path" "Gray" | |
| if (Test-Path $path) { | |
| $size = (Get-ChildItem $path -Recurse -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum | |
| $sizeMB = [math]::Round($size / 1MB, 2) | |
| Write-ColorOutput " Found cache: $sizeMB MB" "Yellow" | |
| Remove-Item $path -Recurse -Force -ErrorAction Stop | |
| Write-ColorOutput " ✓ Cleared: $path" "Green" | |
| $clearedCount++ | |
| } else { | |
| Write-ColorOutput " No cache found: $path" "Gray" | |
| } | |
| } | |
| if ($clearedCount -gt 0) { | |
| Write-ColorOutput " ✓ Store cache cleared successfully" "Green" | |
| return $true | |
| } else { | |
| Write-ColorOutput " ✓ No Store cache found to clear" "Green" | |
| return $true | |
| } | |
| } | |
| catch { | |
| Write-ColorOutput " ✗ Failed to clear Store cache: $($_.Exception.Message)" "Red" | |
| return $false | |
| } | |
| } | |
| # Function to test network connectivity | |
| function Test-NetworkConnectivity { | |
| $testDomains = @("msftncsi.com", "dns.msftncsi.com", "www.msftconnecttest.com") | |
| $successCount = 0 | |
| Write-ColorOutput " Network Connectivity Tests:" "White" | |
| foreach ($domain in $testDomains) { | |
| try { | |
| Write-ColorOutput " Testing: $domain" "Gray" | |
| $result = Test-NetConnection -ComputerName $domain -Port 80 -InformationLevel Quiet -WarningAction SilentlyContinue | |
| if ($result) { | |
| Write-ColorOutput " ✓ $domain - Connected" "Green" | |
| $successCount++ | |
| } else { | |
| Write-ColorOutput " ✗ $domain - Failed" "Red" | |
| } | |
| } | |
| catch { | |
| Write-ColorOutput " ✗ $domain - Error: $($_.Exception.Message)" "Red" | |
| } | |
| } | |
| Write-ColorOutput " Connectivity test results: $successCount/$($testDomains.Count) domains accessible" $(if ($successCount -eq $testDomains.Count) { "Green" } else { "Yellow" }) | |
| return $successCount -eq $testDomains.Count | |
| } | |
| # Function to fix Delivery Optimization settings | |
| function Repair-DeliveryOptimization { | |
| Write-ColorOutput " Delivery Optimization Registry Settings:" "White" | |
| $successCount = 0 | |
| $totalSettings = 0 | |
| # Fix Delivery Optimization settings | |
| $settings = @( | |
| @{ | |
| Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" | |
| Name = "DODownloadMode" | |
| Value = "1" | |
| Type = "DWORD" | |
| Description = "Delivery Optimization Download Mode (Policy)" | |
| }, | |
| @{ | |
| Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" | |
| Name = "DODownloadMode" | |
| Value = "1" | |
| Type = "DWORD" | |
| Description = "Delivery Optimization Download Mode (Config)" | |
| }, | |
| @{ | |
| Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization" | |
| Name = "SystemSettingsDownloadMode" | |
| Value = "1" | |
| Type = "DWORD" | |
| Description = "System Settings Download Mode" | |
| } | |
| ) | |
| foreach ($setting in $settings) { | |
| $totalSettings++ | |
| if (Test-RegistryValue -RegistryPath $setting.Path -ValueName $setting.Name -ExpectedValue $setting.Value -ValueType $setting.Type -Description $setting.Description) { | |
| $successCount++ | |
| } | |
| } | |
| return $successCount -eq $totalSettings | |
| } | |
| # Function to fix Network Connectivity Status Indicator settings | |
| function Repair-NetworkConnectivitySettings { | |
| Write-ColorOutput " Network Connectivity Status Indicator Settings:" "White" | |
| $successCount = 0 | |
| $totalSettings = 0 | |
| # Fix NCSI settings | |
| $settings = @( | |
| @{ | |
| Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\NetworkConnectivityStatusIndicator" | |
| Name = "NoActiveProbe" | |
| Value = "0" | |
| Type = "DWORD" | |
| Description = "Enable Active Connectivity Tests" | |
| }, | |
| @{ | |
| Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\NetworkConnectivityStatusIndicator" | |
| Name = "DisablePassivePolling" | |
| Value = "0" | |
| Type = "DWORD" | |
| Description = "Enable Passive Connectivity Tests" | |
| }, | |
| @{ | |
| Path = "HKLM:\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet" | |
| Name = "EnableActiveProbing" | |
| Value = "1" | |
| Type = "DWORD" | |
| Description = "Enable Active Probing" | |
| }, | |
| @{ | |
| Path = "HKLM:\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet" | |
| Name = "PassivePollPeriod" | |
| Value = "150000" | |
| Type = "DWORD" | |
| Description = "Passive Poll Period" | |
| } | |
| ) | |
| foreach ($setting in $settings) { | |
| $totalSettings++ | |
| if (Test-RegistryValue -RegistryPath $setting.Path -ValueName $setting.Name -ExpectedValue $setting.Value -ValueType $setting.Type -Description $setting.Description) { | |
| $successCount++ | |
| } | |
| } | |
| return $successCount -eq $totalSettings | |
| } | |
| # Function to reset Windows Store apps | |
| function Reset-WindowsStoreApps { | |
| try { | |
| Write-ColorOutput " Windows Store Apps Reset:" "White" | |
| # Get all installed Store apps | |
| $storeApps = Get-AppxPackage -AllUsers | Where-Object { $_.PackageFamilyName -like "*WindowsStore*" -or $_.Name -eq "Microsoft.WindowsStore" } | |
| if ($storeApps) { | |
| Write-ColorOutput " Found $($storeApps.Count) Store apps to reset" "Yellow" | |
| foreach ($app in $storeApps) { | |
| Write-ColorOutput " Resetting: $($app.Name)" "Gray" | |
| try { | |
| Add-AppxPackage -DisableDevelopmentMode -Register "$($app.InstallLocation)\AppXManifest.xml" -ErrorAction SilentlyContinue | |
| Write-ColorOutput " ✓ Reset: $($app.Name)" "Green" | |
| } | |
| catch { | |
| Write-ColorOutput " ⚠ Could not reset: $($app.Name)" "Yellow" | |
| } | |
| } | |
| Write-ColorOutput " ✓ Store apps reset completed" "Green" | |
| return $true | |
| } else { | |
| Write-ColorOutput " ✓ No Store apps found to reset" "Green" | |
| return $true | |
| } | |
| } | |
| catch { | |
| Write-ColorOutput " ✗ Failed to reset Store apps: $($_.Exception.Message)" "Red" | |
| return $false | |
| } | |
| } | |
| # Main script execution | |
| function Main { | |
| # Check for administrator privileges | |
| if (-not (Test-Administrator)) { | |
| Restart-AsAdministrator | |
| } | |
| # Display header | |
| Write-ColorOutput "`n" "White" | |
| Write-ColorOutput "╔══════════════════════════════════════════════════════════════╗" "Cyan" | |
| Write-ColorOutput "║ WINDOWS STORE FIX SCRIPT ║" "Cyan" | |
| Write-ColorOutput "║ ║" "Cyan" | |
| Write-ColorOutput "║ This script fixes Windows Store installation issues ║" "Cyan" | |
| Write-ColorOutput "║ by reverting changes made by privacy-script.bat ║" "Cyan" | |
| Write-ColorOutput "║ Fixes error 0x80004002 (E_NOINTERFACE) ║" "Cyan" | |
| Write-ColorOutput "╚══════════════════════════════════════════════════════════════╝" "Cyan" | |
| Write-ColorOutput "`n" "White" | |
| # Display warning and get confirmation | |
| if (-not $Force) { | |
| Write-ColorOutput "WARNING: This script will make system changes to restore Windows Store functionality." "Yellow" | |
| Write-ColorOutput "The following changes will be made:" "White" | |
| Write-ColorOutput " • Enable Delivery Optimization Service" "White" | |
| Write-ColorOutput " • Enable Windows Update Service" "White" | |
| Write-ColorOutput " • Fix Delivery Optimization registry settings" "White" | |
| Write-ColorOutput " • Fix Network Connectivity Status Indicator settings" "White" | |
| Write-ColorOutput " • Remove network connectivity test blocking" "White" | |
| Write-ColorOutput " • Restore NCSI app (if possible)" "White" | |
| Write-ColorOutput " • Clear Microsoft Store cache" "White" | |
| Write-ColorOutput " • Reset Windows Store apps" "White" | |
| Write-ColorOutput "`n" "White" | |
| if (-not (Get-UserConfirmation "Do you want to continue?")) { | |
| Write-ColorOutput "Operation cancelled by user." "Yellow" | |
| return | |
| } | |
| } | |
| $successCount = 0 | |
| $totalSteps = 9 | |
| # Step 1: Check and fix Delivery Optimization Service | |
| Show-Step "1" "Checking Delivery Optimization Service" | |
| $doService = Test-ServiceStatus "DoSvc" "Delivery Optimization Service" | |
| if ($doService) { | |
| if ($doService.Status -ne "Running" -or $doService.StartType -ne "Automatic") { | |
| Write-ColorOutput " Fixing Delivery Optimization Service..." "Yellow" | |
| if (Enable-Service "DoSvc" "Delivery Optimization Service") { | |
| $successCount++ | |
| } | |
| } else { | |
| Write-ColorOutput " ✓ Delivery Optimization Service is already properly configured" "Green" | |
| $successCount++ | |
| } | |
| } else { | |
| Write-ColorOutput " ⚠ Delivery Optimization Service not found or not accessible" "Yellow" | |
| Write-ColorOutput " This may be normal on some Windows versions" "Yellow" | |
| $successCount++ | |
| } | |
| # Step 2: Check and fix Windows Update Service | |
| Show-Step "2" "Checking Windows Update Service" | |
| $wuService = Test-ServiceStatus "wuauserv" "Windows Update Service" | |
| if ($wuService) { | |
| if ($wuService.Status -ne "Running" -or $wuService.StartType -ne "Automatic") { | |
| Write-ColorOutput " Fixing Windows Update Service..." "Yellow" | |
| if (Enable-Service "wuauserv" "Windows Update Service") { | |
| $successCount++ | |
| } | |
| } else { | |
| Write-ColorOutput " ✓ Windows Update Service is already properly configured" "Green" | |
| $successCount++ | |
| } | |
| } else { | |
| Write-ColorOutput " ✗ Windows Update Service not found or not accessible" "Red" | |
| } | |
| # Step 3: Fix Delivery Optimization registry settings | |
| Show-Step "3" "Fixing Delivery Optimization Registry Settings" | |
| if (Repair-DeliveryOptimization) { | |
| $successCount++ | |
| } | |
| # Step 4: Fix Network Connectivity Status Indicator settings | |
| Show-Step "4" "Fixing Network Connectivity Status Indicator Settings" | |
| if (Repair-NetworkConnectivitySettings) { | |
| $successCount++ | |
| } | |
| # Step 5: Remove network connectivity test blocking | |
| Show-Step "5" "Removing Network Connectivity Test Blocking" | |
| $blockedDomains = @("msftncsi.com", "dns.msftncsi.com", "ipv6.msftncsi.com", "msftconnecttest.com", "www.msftconnecttest.com", "ipv6.msftconnecttest.com") | |
| if (Remove-HostsEntries $blockedDomains) { | |
| $successCount++ | |
| } | |
| # Step 6: Test network connectivity | |
| Show-Step "6" "Testing Network Connectivity" | |
| if (Test-NetworkConnectivity) { | |
| Write-ColorOutput " ✓ Network connectivity tests passed" "Green" | |
| $successCount++ | |
| } else { | |
| Write-ColorOutput " ⚠ Some network connectivity tests failed" "Yellow" | |
| Write-ColorOutput " This may be due to network configuration or firewall settings" "Yellow" | |
| $successCount++ | |
| } | |
| # Step 7: Restore NCSI app | |
| Show-Step "7" "Restoring NCSI App" | |
| if (Restore-NCSIApp) { | |
| $successCount++ | |
| } else { | |
| $successCount++ # Count as success since it's not critical | |
| } | |
| # Step 8: Clear Store cache | |
| Show-Step "8" "Clearing Microsoft Store Cache" | |
| if (Clear-StoreCache) { | |
| $successCount++ | |
| } | |
| # Step 9: Reset Windows Store apps | |
| Show-Step "9" "Resetting Windows Store Apps" | |
| if (Reset-WindowsStoreApps) { | |
| $successCount++ | |
| } | |
| # Display results | |
| Write-ColorOutput "`n" "White" | |
| Write-ColorOutput "╔══════════════════════════════════════════════════════════════╗" "Cyan" | |
| Write-ColorOutput "║ RESULTS ║" "Cyan" | |
| Write-ColorOutput "╚══════════════════════════════════════════════════════════════╝" "Cyan" | |
| Write-ColorOutput "`n" "White" | |
| Write-ColorOutput "Completed $successCount out of $totalSteps steps successfully." $(if ($successCount -eq $totalSteps) { "Green" } else { "Yellow" }) | |
| if ($successCount -eq $totalSteps) { | |
| Write-ColorOutput "`n✓ All fixes applied successfully!" "Green" | |
| Write-ColorOutput "`nNext steps:" "Cyan" | |
| Write-ColorOutput " 1. Restart your computer" "White" | |
| Write-ColorOutput " 2. Try installing an app from Microsoft Store" "White" | |
| Write-ColorOutput " 3. If issues persist, run Windows Store troubleshooter:" "White" | |
| Write-ColorOutput " Settings > Update & Security > Troubleshoot > Windows Store Apps" "White" | |
| } else { | |
| Write-ColorOutput "`n⚠ Some fixes could not be applied completely." "Yellow" | |
| Write-ColorOutput "`nAdditional troubleshooting steps:" "Cyan" | |
| Write-ColorOutput " 1. Restart your computer" "White" | |
| Write-ColorOutput " 2. Run Windows Store troubleshooter" "White" | |
| Write-ColorOutput " 3. Try running: DISM /Online /Cleanup-Image /RestoreHealth" "White" | |
| Write-ColorOutput " 4. Try running: sfc /scannow" "White" | |
| Write-ColorOutput " 5. For error 0x80004002, also try:" "White" | |
| Write-ColorOutput " - Reset Windows Store: wsreset.exe" "White" | |
| Write-ColorOutput ' - Re-register Windows Store: Get-AppXPackage -AllUsers -Name Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}' 'White' } | |
| Write-ColorOutput "`nPress any key to exit..." "White" | |
| if (-not $Silent) { | |
| $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | |
| } | |
| } | |
| # Execute main function | |
| Main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment