Files
qt5/coin/pre-provisioning/qtci-windows-10_21H2-x86_64/disable-windows-update-medic.ps1
Heikki Halmet c34960c8bd Add pre-provisioning files for Windows 10 21H2
Change-Id: I9e6e1423b1e287aff0be8ea2b29c95838ed10de5
Reviewed-by: Ville-Pekka Karhu <ville-pekka.karhu@qt.io>
2021-12-29 08:42:22 +02:00

26 lines
817 B
PowerShell

# Windows Update Medic Service (WaaSMedicSvc)'PerformRemediation' helps recover update-related services to the supported configuration.
# WaasMedicSvc keeps re-starting Windows Update, even if it disabled manually.
# Even Admin user don't have privileged to disable PerformRemediation from Task Scheduler which means that WaaSMedicSvc.dll need's to be removed from the system
$limit = (Get-Date).AddMinutes(20)
$path = "C:\Windows\System32\WaaSMedicAgent.exe"
DO {
takeown /F $path
icacls $path /grant Administrators:f
Write-host "Deleting $path"
Try {
del $path
}
Catch [System.UnauthorizedAccessException] {
Write-host "Access to the path '$path' is denied."
Continue
}
if ((Get-Date) -gt $limit) {
exit 1
}
}while (Test-Path -Path "$path")