| Server IP : 123.56.80.60 / Your IP : 216.73.216.78 Web Server : Apache/2.4.54 (Win32) OpenSSL/1.1.1s PHP/7.4.33 mod_fcgid/2.3.10-dev System : Windows NT iZhx3sob14hnz7Z 10.0 build 14393 (Windows Server 2016) i586 User : SYSTEM ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Windows/diagnostics/system/WindowsUpdate/ |
Upload File : |
# Copyright © 2012, Microsoft Corporation. All rights reserved.
# Load Utilities
. .\utils_SetupEnv.ps1
. .\cl_Service.ps1
. .\cl_windowsversion.ps1
. .\cl_mutexverifiers.ps1
Import-LocalizedData -BindingVariable DC_Strings -FileName CL_LocalizationData
cd "$env:windir\system32"
function DeleteBakFolder()
{
$bak = "softwaredistribution.bak"
if(test-path (join-path $env:windir "\$bak")){
del (join-path $env:windir "\$bak*") -force -Recurse
}
}
#Collect files First
Function Collect()
{
$str = $DC_Strings.ID_CollectFileProgressActivity
Write-DiagProgress -activity $str
$datastorefile = "$env:Windir\softwaredistribution\datastore\datastore.edb"
#Commenting since Winodws 10 does not support Windowsupdate.log
#$updatefile = "$env:Windir\Windowsupdate.log"
$dismlog = "$env:windir\logs\DISM\dism.log"
<#if(TestFileInUse $updatefile)
{
sleep 2
}#>
$zipPath=($env:temp+"\WUDiagTempFolder\DataStoreAndWULogFiles.zip")
if(test-path $zipPath){
del $zipPath -Force -ErrorAction SilentlyContinue
}
$location = "$env:temp\WUDiagTempFolder\DataStoreCollectedFiles"
New-Item -path $location -ItemType directory -ea silentlycontinue
Copy-Item $datastorefile $location -ErrorAction SilentlyContinue
#Copy-Item $updatefile $location
Arm-Zip ("$env:temp\WUDiagTempFolder\DataStoreCollectedFiles") ($zipPath)
Remove-Item -path $location -Recurse -Force -ErrorAction SilentlyContinue
$size = Get-SizeFormat(dir $zipPath | Select-Object -ExpandProperty Length)
#$size = Get-SizeFormat (Calculatesize (dir $zipPath -recurse|%{$_.FullName}))
Update-DiagReport -id "RS_DataStore" -file $zipPath -name "DataStoreAndWULogFiles.zip" -description ($size) -Verbosity Informational
return $true
}
function RestartService()
{
&{
Fix-ServiceWithDebugFile "wuauserv" ("$env:temp\WUDiagTempFolder\outputreport.txt") "RS_DataStore : "
} trap [Exception]{
[string]$str = ($DC_Strings.ID_ERROR_MSG_SERVICE).replace("%ServiceName%","wuauserv")
$str | convertto-xml | update-diagreport -id "RS_DataStore" -name "$str" -verbosity informational
}
}
function AddEDBBacK()
{
sleep 2
$BakPath = join-path $env:windir "\$global:SDFbak\DataStore\DataStore.edb"
$SDFPath = join-path "$env:windir" "softwaredistribution\DataStore"
if(!(test-path $BakPath))
{
return
}
$timeout = [Timespan]"0:0:15"
$start = Get-Date
do{
if(Test-path $SDFPath)
{
Servicer "wuauserv" "stopped"
Copy-Item $BakPath $SDFPath -force
break;
}
sleep 1
}while (((Get-Date) - $start) -le $timeout)
if(!(Test-path $SDFPath))
{
Servicer "wuauserv" "stopped"
$d = new-item $SDFPath -type directory -force
Copy-Item $BakPath $SDFPath -force
}
RestartService
}
function Renamesoftwaredistribution()
{
[int]$i=1
trap [Exception] {
[string]$str=$Error[0]
$str | convertto-xml | update-diagreport -id RS_DataStore -name "Error$i" -verbosity informational
#$str+$i
Continue
}
Write-DiagProgress -activity $DC_Strings.ID_NAME_RC_DataStoreProgress
[int]$j=1
$folder = join-path "$env:systemroot" "softwaredistribution"
$bak = "softwaredistribution.bak"
if(!(test-path (join-path $env:systemroot "\$bak"))){
}else{
while((test-path (join-path $env:systemroot ("$bak"+$j))))
{
$j=$j+1
#$j
}
$bak += $j
}
ren $folder $bak -Force -ErrorAction Stop
$global:SDFbak = $bak
Write-DiagProgress -activity " "
return $true
}
Function RemoveRegistryEntry
{
Param([String]$RegKey)
If(Test-Path -Path $RegKey)
{
Remove-Item -Path $RegKey -Recurse -Force
}
}
#*=================================================================================
#UpdateVerifierfixed
#*=================================================================================
function UpdateVerifierfixed()
{
param( [bool]$status = $false,$tempfname)
trap [Exception]{continue;}
if(Test-Path "$Env:TEMP\$tempfname")
{
del "$Env:TEMP\$tempfname" -Force
$path = New-Item -Path "$Env:TEMP\$tempfname" -ItemType file
}
$verfiyobj = New-Object psObject
Add-Member -InputObject $verfiyobj -MemberType noteproperty -Name status -Value $status
Export-Clixml -Path "$Env:TEMP\$tempfname" -InputObject $verfiyobj -Force
}
#*================================================================================
#Resolve
#*================================================================================
try
{
Servicer wuauserv "stopped"
#Stop dosvc service
Servicer dosvc "stopped"
Collect
Renamesoftwaredistribution
#Delete the registry entries
RemoveRegistryEntry -RegKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Jobs"
#Start dosvc service
Servicer dosvc "Running"
SetServiceRunning "wuauserv" "RS_DataStore" -nostop
# Adding EDB File Back
AddEDBBack
DeleteBakFolder
UpdateVerifierfixed $true "rsdatastoreWU.xml"
#runningResolver "DataStore" $errcode
}
catch
{
UpdateVerifierfixed $false "rsdatastoreWU.xml"
}
#*=================================================================================
#End
#*=================================================================================