Skip to content

Instantly share code, notes, and snippets.

@yon2004
Created July 27, 2018 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yon2004/6193a168cd9fde7aed9f16942f02efd4 to your computer and use it in GitHub Desktop.
Save yon2004/6193a168cd9fde7aed9f16942f02efd4 to your computer and use it in GitHub Desktop.
A script that can be run to fix the windows 10 bug that causes corruption of the software distribution folder. 0x80242006
$log_path = "$($env:TEMP)\WindowsUpdateFix.txt"
$folder_name = "$($env:windir)\SoftwareDistribution"
$folder_name_new = "$($env:windir)\SoftwareDistribution.27072018"
Start-Transcript -Path $log_path -Append
Write-Output "log_path: $($log_path)"
Write-Output "folder_name: $($folder_name)"
Write-Output "folder_name_new: $($folder_name_new)"
If(Test-Path -Path $folder_name_new){
Write-Output "$($folder_name_new) already exists stopping WindowsUpdateFix"
} else {
Get-Service @('wuauserv') | Set-Service -StartupType Disabled -Verbose
Get-Service @('bits','appidsvc', 'cryptsvc', 'wuauserv') |Stop-Service -Force -Verbose
Move-Item -Path $folder_name -Destination $folder_name_new -Verbose -Force
Get-Service @('wuauserv') | Set-Service -StartupType Manual -Verbose
Get-Service @('bits','appidsvc', 'cryptsvc', 'wuauserv') |Start-Service -Verbose
}
Stop-Transcript
@yon2004
Copy link
Author

yon2004 commented Jul 27, 2018

powershell.exe -ExecutionPolicy Bypass -File .\WindowsUpdateFix.ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment