summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2018-01-17 15:57:27 +0100
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2018-01-18 21:08:25 +0000
commit99595f44f1b3a3c35d8decc671a8933f65220cf3 (patch)
treecee7acb04b35f7ed9d52ada11fc3d3aa8764f68d
parentb86b3a757b473e86aae7f246d2f1a8e0ae8e54b7 (diff)
Provisioning: Fix disabling windows updates
On some machines the updates were already disabled, which lead to the call to disable the service failing. Now we just move on without error. Change-Id: Ia48f7164c23dfe24e24548558d582cdc0190b7e3 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
-rw-r--r--coin/provisioning/common/windows/disable-windows-updates.ps121
1 files changed, 19 insertions, 2 deletions
diff --git a/coin/provisioning/common/windows/disable-windows-updates.ps1 b/coin/provisioning/common/windows/disable-windows-updates.ps1
index 1a014733..05215e20 100644
--- a/coin/provisioning/common/windows/disable-windows-updates.ps1
+++ b/coin/provisioning/common/windows/disable-windows-updates.ps1
@@ -33,5 +33,22 @@
# This script disables the automatic Windows updates
-stop-service wuauserv
-set-service wuauserv –startup disabled
+$service = get-service wuauserv
+if (-not $service) {
+ Write-Host "Windows Update service not found."
+ exit 0
+}
+
+if ($service.Status -eq "Stopped") {
+ Write-Host "Windows Update service already stopped."
+} else {
+ Write-Host "Stopping Windows Update service."
+ stop-service wuauserv
+}
+
+$startup = Get-WmiObject Win32_Service | Where-Object {$_.Name -eq "wuauserv"} | Select -ExpandProperty "StartMode"
+if ($startup -ne "Disabled") {
+ set-service wuauserv -startup disabled
+} else {
+ Write-Host "Windows Update service startup already disabled."
+}