mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-08-09 17:41:14 +10:00
Fix progress, update profiles, and documentation links (#4845)
* Improve O&O ShutUp10++ download flow * Refine Windows Update profile behavior and docs * Fix documentation link regressions * Restore updates when applying recommended profile
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
function Save-WinUtilFile {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Downloads a file and reports transfer progress.
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[uri]$Uri,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[string]$DestinationPath,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[scriptblock]$ProgressCallback
|
||||
)
|
||||
|
||||
$response = $null
|
||||
$responseStream = $null
|
||||
$outputStream = $null
|
||||
|
||||
try {
|
||||
$request = [System.Net.WebRequest]::Create($Uri)
|
||||
$response = $request.GetResponse()
|
||||
$totalBytes = $response.ContentLength
|
||||
$responseStream = $response.GetResponseStream()
|
||||
$outputStream = [System.IO.File]::Create($DestinationPath)
|
||||
$buffer = New-Object byte[] 81920
|
||||
$downloadedBytes = 0L
|
||||
$lastPercent = -1
|
||||
|
||||
while (($bytesRead = $responseStream.Read($buffer, 0, $buffer.Length)) -gt 0) {
|
||||
$outputStream.Write($buffer, 0, $bytesRead)
|
||||
$downloadedBytes += $bytesRead
|
||||
|
||||
if ($totalBytes -gt 0) {
|
||||
$percent = [Math]::Min(100, [int](($downloadedBytes / $totalBytes) * 100))
|
||||
if ($percent -ne $lastPercent) {
|
||||
& $ProgressCallback $percent
|
||||
$lastPercent = $percent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($lastPercent -ne 100) {
|
||||
& $ProgressCallback 100
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if ($null -ne $outputStream) {
|
||||
$outputStream.Dispose()
|
||||
}
|
||||
if ($null -ne $responseStream) {
|
||||
$responseStream.Dispose()
|
||||
}
|
||||
if ($null -ne $response) {
|
||||
$response.Dispose()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,50 @@
|
||||
function Invoke-WPFOOSU {
|
||||
try {
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
if ($sync.ProcessRunning) {
|
||||
Show-WinUtilMessage -Message "Another process is currently running." -Title "WinUtil" -Button "OK" -Icon "Warning"
|
||||
return
|
||||
}
|
||||
|
||||
Invoke-WebRequest -Uri https://dl5.oo-software.com/files/ooshutup10/OOSU10.exe -OutFile "$winutildir\ooshutup10.exe"
|
||||
Start-Process -FilePath "$winutildir\ooshutup10.exe"
|
||||
$downloadPath = Join-Path $sync.winutildir "ooshutup10.exe"
|
||||
$sync.ProcessRunning = $true
|
||||
|
||||
$ProgressPreference = 'Continue'
|
||||
} catch {
|
||||
Write-Error "Couldn't download O&O ShutUp10. Please make sure you have an active Internet connection."
|
||||
Invoke-WPFRunspace -ParameterList @(,("downloadPath", $downloadPath)) -ScriptBlock {
|
||||
param($downloadPath)
|
||||
|
||||
$hasUI = $null -ne $sync.Form -and $null -ne $sync.Form.Dispatcher
|
||||
|
||||
try {
|
||||
Write-WinUtilLog -Component "OOSU" -Message "Downloading O&O ShutUp10++."
|
||||
if ($hasUI) {
|
||||
Set-WinUtilTweaksProgressIndicator -Visible $true -Label "Downloading O&O ShutUp10++ (0%)" -Percent 0
|
||||
}
|
||||
|
||||
Save-WinUtilFile -Uri "https://dl5.oo-software.com/files/ooshutup10/OOSU10.exe" -DestinationPath $downloadPath -ProgressCallback {
|
||||
param($percent)
|
||||
|
||||
if ($hasUI) {
|
||||
Set-WinUtilTweaksProgressIndicator -Visible $true -Label "Downloading O&O ShutUp10++ ($percent%)" -Percent $percent
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasUI) {
|
||||
Set-WinUtilTweaksProgressIndicator -Visible $true -Label "Launching O&O ShutUp10++" -Percent 100
|
||||
}
|
||||
Start-Process -FilePath $downloadPath
|
||||
|
||||
Write-WinUtilLog -Component "OOSU" -Message "O&O ShutUp10++ launched."
|
||||
if ($hasUI) {
|
||||
Set-WinUtilTweaksProgressIndicator -Visible $true -Label "O&O ShutUp10++ launched" -Percent 100
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-WinUtilLog -Level "ERROR" -Component "OOSU" -Message "O&O ShutUp10++ download failed: $($_.Exception.Message)"
|
||||
if ($hasUI) {
|
||||
Set-WinUtilTweaksProgressIndicator -Visible $true -Label "O&O ShutUp10++ download failed" -Percent 100
|
||||
}
|
||||
Write-Error "Couldn't download O&O ShutUp10. Please make sure you have an active Internet connection."
|
||||
}
|
||||
finally {
|
||||
$sync.ProcessRunning = $false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,11 +404,16 @@ function Invoke-WPFUIElements {
|
||||
$textBlock.ToolTip = $entryInfo.Link
|
||||
$textBlock.Style = $HoverTextBlockStyle
|
||||
$textBlock.UseLayoutRounding = $true
|
||||
|
||||
|
||||
$textBlock.VerticalAlignment = "Center"
|
||||
$textBlock.SetResourceReference([Windows.Controls.Control]::FontSizeProperty, "FontSize")
|
||||
$textBlock.Tag = $checkBox
|
||||
|
||||
$textBlock.Add_MouseUp({
|
||||
[System.Object]$Sender = $args[0]
|
||||
Start-Process $Sender.ToolTip -ErrorAction Stop
|
||||
})
|
||||
|
||||
$updateLinkMargin = {
|
||||
[System.Object]$Sender = $args[0]
|
||||
$linkedCheckBox = $Sender.Tag
|
||||
|
||||
@@ -5,22 +5,51 @@ function Invoke-WPFUpdatesdefault {
|
||||
Resets Windows Update settings to default
|
||||
|
||||
#>
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
Write-WinUtilLog -Component "Updates" -Message "Resetting Windows Update settings to default."
|
||||
|
||||
Write-Host "Removing Windows Update policy settings..." -ForegroundColor Green
|
||||
Write-WinUtilLog -Component "Updates" -Message "Removing Windows Update policy registry paths."
|
||||
Write-Host "Removing Windows Update settings managed by WinUtil..." -ForegroundColor Green
|
||||
Write-WinUtilLog -Component "Updates" -Message "Removing Windows Update registry values managed by WinUtil."
|
||||
|
||||
Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Recurse -Force
|
||||
Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" -Recurse -Force
|
||||
Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Recurse -Force
|
||||
Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Recurse -Force
|
||||
Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Recurse -Force
|
||||
Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Recurse -Force
|
||||
$registryValues = @(
|
||||
@{
|
||||
Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"
|
||||
Names = @("NoAutoUpdate", "AUOptions", "NoAutoRebootWithLoggedOnUsers", "AUPowerManagement")
|
||||
},
|
||||
@{
|
||||
Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"
|
||||
Names = @("ExcludeWUDriversInQualityUpdate", "DeferFeatureUpdates", "DeferFeatureUpdatesPeriodInDays", "DeferQualityUpdates", "DeferQualityUpdatesPeriodInDays")
|
||||
},
|
||||
@{
|
||||
Path = "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings"
|
||||
Names = @("BranchReadinessLevel", "DeferFeatureUpdatesPeriodInDays", "DeferQualityUpdatesPeriodInDays")
|
||||
},
|
||||
@{
|
||||
Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata"
|
||||
Names = @("PreventDeviceMetadataFromNetwork")
|
||||
},
|
||||
@{
|
||||
Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching"
|
||||
Names = @("DontPromptForWindowsUpdate", "DontSearchWindowsUpdate", "DriverUpdateWizardWuSearchEnabled")
|
||||
},
|
||||
@{
|
||||
Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config"
|
||||
Names = @("DODownloadMode")
|
||||
}
|
||||
)
|
||||
|
||||
Write-Host "Showing Windows Updates in settings..."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Showing Windows Update settings page."
|
||||
Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name SettingsPageVisibility
|
||||
foreach ($registryEntry in $registryValues) {
|
||||
foreach ($valueName in $registryEntry.Names) {
|
||||
Remove-ItemProperty -Path $registryEntry.Path -Name $valueName -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
$explorerPolicyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer"
|
||||
$settingsPageVisibility = (Get-ItemProperty -Path $explorerPolicyPath -Name "SettingsPageVisibility" -ErrorAction SilentlyContinue).SettingsPageVisibility
|
||||
if ($settingsPageVisibility -eq "hide:windowsupdate") {
|
||||
Write-Host "Removing WinUtil's legacy Windows Update page restriction..."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Removing the legacy Windows Update settings page restriction."
|
||||
Remove-ItemProperty -Path $explorerPolicyPath -Name "SettingsPageVisibility" -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Write-Host "Reenabling Windows Update Services..." -ForegroundColor Green
|
||||
Write-WinUtilLog -Component "Updates" -Message "Restoring Windows Update service startup types."
|
||||
@@ -35,12 +64,8 @@ function Invoke-WPFUpdatesdefault {
|
||||
|
||||
Write-Host "Restored UsoSvc to Automatic."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Starting UsoSvc service and restoring startup type to Automatic."
|
||||
Start-Service -Name UsoSvc
|
||||
Set-Service -Name UsoSvc -StartupType Automatic
|
||||
|
||||
Write-Host "Restored WaaSMedicSvc to Manual."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Restoring WaaSMedicSvc service to Manual."
|
||||
Set-Service -Name WaaSMedicSvc -StartupType Manual
|
||||
Start-Service -Name UsoSvc
|
||||
|
||||
Write-Host "Enabling update related scheduled tasks..." -ForegroundColor Green
|
||||
Write-WinUtilLog -Component "Updates" -Message "Enabling update related scheduled tasks."
|
||||
@@ -54,13 +79,9 @@ function Invoke-WPFUpdatesdefault {
|
||||
'\Microsoft\WindowsUpdate\*'
|
||||
|
||||
foreach ($Task in $Tasks) {
|
||||
Get-ScheduledTask -TaskPath $Task | Enable-ScheduledTask -ErrorAction SilentlyContinue
|
||||
Get-ScheduledTask -TaskPath $Task -ErrorAction SilentlyContinue | Enable-ScheduledTask -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Write-Host "Windows Local Policies Reset to Default."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Resetting local security policy to defaults with secedit."
|
||||
secedit /configure /cfg "$Env:SystemRoot\inf\defltbase.inf" /db defltbase.sdb
|
||||
|
||||
Write-Host "===================================================" -ForegroundColor Green
|
||||
Write-Host "--- Windows Update Settings Reset to Default ---" -ForegroundColor Green
|
||||
Write-Host "===================================================" -ForegroundColor Green
|
||||
|
||||
@@ -8,7 +8,17 @@ function Invoke-WPFUpdatesdisable {
|
||||
Disabling Windows Update is not recommended. This is only for advanced users who know what they are doing.
|
||||
|
||||
#>
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
$confirmation = Show-WinUtilMessage `
|
||||
-Message "Disabling Windows Update stops update services, disables scheduled tasks, and clears downloaded update files. Security updates will not be installed until defaults are restored. Continue?" `
|
||||
-Title "Disable Windows Update?" `
|
||||
-Button "YesNo" `
|
||||
-Icon "Warning"
|
||||
|
||||
if ($confirmation -ne "Yes") {
|
||||
Write-WinUtilLog -Component "Updates" -Message "Windows Update disable workflow cancelled."
|
||||
return
|
||||
}
|
||||
|
||||
Write-WinUtilLog -Component "Updates" -Message "Disabling Windows Update settings."
|
||||
|
||||
Write-Host "Configuring registry settings..." -ForegroundColor Yellow
|
||||
@@ -21,24 +31,14 @@ function Invoke-WPFUpdatesdisable {
|
||||
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Force
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -Type DWord -Value 0
|
||||
|
||||
Write-Host "Hiding Windows Updates from settings..."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Hiding Windows Update settings page."
|
||||
Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name SettingsPageVisibility -Value hide:windowsupdate
|
||||
foreach ($serviceName in @("BITS", "wuauserv", "UsoSvc")) {
|
||||
Write-Host "Stopping and disabling $serviceName service."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Stopping and disabling $serviceName service."
|
||||
Stop-Service -Name $serviceName -Force -ErrorAction SilentlyContinue
|
||||
Set-Service -Name $serviceName -StartupType Disabled
|
||||
}
|
||||
|
||||
Write-Host "Disabled BITS Service."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Disabling BITS service."
|
||||
Set-Service -Name BITS -StartupType Disabled
|
||||
|
||||
Write-Host "Disabled wuauserv Service."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Disabling wuauserv service."
|
||||
Set-Service -Name wuauserv -StartupType Disabled
|
||||
|
||||
Write-Host "Disabled UsoSvc Service."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Stopping and disabling UsoSvc service."
|
||||
Stop-Service -Name UsoSvc -Force
|
||||
Set-Service -Name UsoSvc -StartupType Disabled
|
||||
|
||||
Remove-Item "C:\Windows\SoftwareDistribution\*" -Recurse -Force
|
||||
Remove-Item -Path "C:\Windows\SoftwareDistribution\*" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Write-Host "Cleared SoftwareDistribution folder."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Cleared SoftwareDistribution folder."
|
||||
|
||||
@@ -54,11 +54,11 @@ function Invoke-WPFUpdatesdisable {
|
||||
'\Microsoft\WindowsUpdate\*'
|
||||
|
||||
foreach ($Task in $Tasks) {
|
||||
Get-ScheduledTask -TaskPath $Task | Disable-ScheduledTask -ErrorAction SilentlyContinue
|
||||
Get-ScheduledTask -TaskPath $Task -ErrorAction SilentlyContinue | Disable-ScheduledTask -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Write-Host "=================================" -ForegroundColor Green
|
||||
Write-Host "--- Updates Are Disabled ---" -ForegroundColor Green
|
||||
Write-Host "--- Windows Update Is Disabled ---" -ForegroundColor Green
|
||||
Write-Host "=================================" -ForegroundColor Green
|
||||
|
||||
Write-Host "Note: You must restart your system in order for all changes to take effect." -ForegroundColor Yellow
|
||||
|
||||
@@ -6,10 +6,9 @@ function Invoke-WPFUpdatessecurity {
|
||||
|
||||
.DESCRIPTION
|
||||
1. Disables driver offering through Windows Update
|
||||
2. Disables Windows Update automatic restart
|
||||
3. Sets Windows Update to Semi-Annual Channel (Targeted)
|
||||
4. Defers feature updates for 365 days
|
||||
5. Defers quality updates for 4 days
|
||||
2. Defers feature updates for 365 days
|
||||
3. Defers quality updates for 4 days
|
||||
4. Prevents automatic restarts while a user is signed in
|
||||
|
||||
#>
|
||||
|
||||
@@ -17,6 +16,32 @@ function Invoke-WPFUpdatessecurity {
|
||||
Write-WinUtilLog -Component "Updates" -Message "Applying recommended Windows Update settings."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Disabling driver offering through Windows Update."
|
||||
|
||||
$windowsUpdatePolicyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"
|
||||
$automaticUpdatePolicyPath = Join-Path $windowsUpdatePolicyPath "AU"
|
||||
|
||||
Write-Host "Restoring Windows Update availability..."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Restoring Windows Update services and scheduled tasks before applying recommended settings."
|
||||
|
||||
Remove-ItemProperty -Path $automaticUpdatePolicyPath -Name "NoAutoUpdate" -ErrorAction SilentlyContinue
|
||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -ErrorAction SilentlyContinue
|
||||
|
||||
Set-Service -Name BITS -StartupType Manual
|
||||
Set-Service -Name wuauserv -StartupType Manual
|
||||
Set-Service -Name UsoSvc -StartupType Automatic
|
||||
Start-Service -Name UsoSvc
|
||||
|
||||
$Tasks =
|
||||
'\Microsoft\Windows\InstallService\*',
|
||||
'\Microsoft\Windows\UpdateOrchestrator\*',
|
||||
'\Microsoft\Windows\UpdateAssistant\*',
|
||||
'\Microsoft\Windows\WaaSMedic\*',
|
||||
'\Microsoft\Windows\WindowsUpdate\*',
|
||||
'\Microsoft\WindowsUpdate\*'
|
||||
|
||||
foreach ($Task in $Tasks) {
|
||||
Get-ScheduledTask -TaskPath $Task -ErrorAction SilentlyContinue | Enable-ScheduledTask -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Force
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -Type DWord -Value 1
|
||||
|
||||
@@ -26,24 +51,30 @@ function Invoke-WPFUpdatessecurity {
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontSearchWindowsUpdate" -Type DWord -Value 1
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DriverUpdateWizardWuSearchEnabled" -Type DWord -Value 0
|
||||
|
||||
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Force
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -Type DWord -Value 1
|
||||
New-Item -Path $windowsUpdatePolicyPath -Force
|
||||
Set-ItemProperty -Path $windowsUpdatePolicyPath -Name "ExcludeWUDriversInQualityUpdate" -Type DWord -Value 1
|
||||
|
||||
Write-Host "Setting cumulative updates back by 1 year and security updates by 4 days..."
|
||||
Write-Host "Deferring feature updates by 365 days and quality updates by 4 days..."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Deferring feature updates by 365 days and quality updates by 4 days."
|
||||
|
||||
New-Item -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Force
|
||||
Set-ItemProperty -Path $windowsUpdatePolicyPath -Name "DeferFeatureUpdates" -Type DWord -Value 1
|
||||
Set-ItemProperty -Path $windowsUpdatePolicyPath -Name "DeferFeatureUpdatesPeriodInDays" -Type DWord -Value 365
|
||||
Set-ItemProperty -Path $windowsUpdatePolicyPath -Name "DeferQualityUpdates" -Type DWord -Value 1
|
||||
Set-ItemProperty -Path $windowsUpdatePolicyPath -Name "DeferQualityUpdatesPeriodInDays" -Type DWord -Value 4
|
||||
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "BranchReadinessLevel" -Type DWord -Value 20
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferFeatureUpdatesPeriodInDays" -Type DWord -Value 365
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferQualityUpdatesPeriodInDays" -Type DWord -Value 4
|
||||
$legacySettingsPath = "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings"
|
||||
foreach ($legacyValue in @("BranchReadinessLevel", "DeferFeatureUpdatesPeriodInDays", "DeferQualityUpdatesPeriodInDays")) {
|
||||
Remove-ItemProperty -Path $legacySettingsPath -Name $legacyValue -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Write-Host "Disabling Windows Update automatic restart..."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Disabling Windows Update automatic restart while users are logged in."
|
||||
Write-Host "Preventing automatic restarts while users are signed in..."
|
||||
Write-WinUtilLog -Component "Updates" -Message "Configuring scheduled automatic updates without restarting while users are signed in."
|
||||
|
||||
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoRebootWithLoggedOnUsers" -Type DWord -Value 1
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUPowerManagement" -Type DWord -Value 0
|
||||
New-Item -Path $automaticUpdatePolicyPath -Force
|
||||
# NoAutoRebootWithLoggedOnUsers only applies when automatic updates use option 4.
|
||||
Set-ItemProperty -Path $automaticUpdatePolicyPath -Name "AUOptions" -Type DWord -Value 4
|
||||
Set-ItemProperty -Path $automaticUpdatePolicyPath -Name "NoAutoRebootWithLoggedOnUsers" -Type DWord -Value 1
|
||||
Set-ItemProperty -Path $automaticUpdatePolicyPath -Name "AUPowerManagement" -Type DWord -Value 0
|
||||
|
||||
Write-Host "================================="
|
||||
Write-Host "-- Updates Set to Recommended ---"
|
||||
|
||||
Reference in New Issue
Block a user