Skip to content

Commit 96d8010

Browse files
Merge branch 'main' into microwin-25h2-prepare
2 parents 5a14531 + e2e9089 commit 96d8010

File tree

5 files changed

+202
-14
lines changed

5 files changed

+202
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ You'll see a new file named `winutil.ps1`, which's created by `Compile.ps1` scri
7979

8080
These are the sponsors that help keep this project alive with monthly contributions.
8181

82-
<!-- sponsors --><a href="https://github.com/TriHydera"><img src="https:&#x2F;&#x2F;github.com&#x2F;TriHydera.png" width="60px" alt="User avatar: TriHydera" /></a><a href="https://github.com/DelDongo"><img src="https:&#x2F;&#x2F;github.com&#x2F;DelDongo.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/markamos"><img src="https:&#x2F;&#x2F;github.com&#x2F;markamos.png" width="60px" alt="User avatar: Mark Amos" /></a><a href="https://github.com/dwelfusius"><img src="https:&#x2F;&#x2F;github.com&#x2F;dwelfusius.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/mews-se"><img src="https:&#x2F;&#x2F;github.com&#x2F;mews-se.png" width="60px" alt="User avatar: Martin Stockzell" /></a><a href="https://github.com/jdiegmueller"><img src="https:&#x2F;&#x2F;github.com&#x2F;jdiegmueller.png" width="60px" alt="User avatar: Jason A. Diegmueller" /></a><a href="https://github.com/robertsandrock"><img src="https:&#x2F;&#x2F;github.com&#x2F;robertsandrock.png" width="60px" alt="User avatar: RMS" /></a><a href="https://github.com/KenichiQaz"><img src="https:&#x2F;&#x2F;github.com&#x2F;KenichiQaz.png" width="60px" alt="User avatar: Stefan" /></a><a href="https://github.com/paulsheets"><img src="https:&#x2F;&#x2F;github.com&#x2F;paulsheets.png" width="60px" alt="User avatar: Paul" /></a><a href="https://github.com/djones369"><img src="https:&#x2F;&#x2F;github.com&#x2F;djones369.png" width="60px" alt="User avatar: Dave J. - WhamGeek" /></a><a href="https://github.com/anthonymendez"><img src="https:&#x2F;&#x2F;github.com&#x2F;anthonymendez.png" width="60px" alt="User avatar: Anthony Mendez" /></a><a href="https://github.com/FatBastard0"><img src="https:&#x2F;&#x2F;github.com&#x2F;FatBastard0.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/DursleyGuy"><img src="https:&#x2F;&#x2F;github.com&#x2F;DursleyGuy.png" width="60px" alt="User avatar: DursleyGuy" /></a><a href="https://github.com/realmuddy"><img src="https:&#x2F;&#x2F;github.com&#x2F;realmuddy.png" width="60px" alt="User avatar: Phillip Waters" /></a><a href="https://github.com/quaszi"><img src="https:&#x2F;&#x2F;github.com&#x2F;quaszi.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/DwayneTheRockLobster1"><img src="https:&#x2F;&#x2F;github.com&#x2F;DwayneTheRockLobster1.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/KieraKujisawa"><img src="https:&#x2F;&#x2F;github.com&#x2F;KieraKujisawa.png" width="60px" alt="User avatar: Kiera Meredith" /></a><a href="https://github.com/danhively"><img src="https:&#x2F;&#x2F;github.com&#x2F;danhively.png" width="60px" alt="User avatar: Dan Hively" /></a><a href="https://github.com/smeletiou"><img src="https:&#x2F;&#x2F;github.com&#x2F;smeletiou.png" width="60px" alt="User avatar: Sotiris Meletiou" /></a><!-- sponsors -->
82+
<!-- sponsors --><a href="https://github.com/TriHydera"><img src="https:&#x2F;&#x2F;github.com&#x2F;TriHydera.png" width="60px" alt="User avatar: TriHydera" /></a><a href="https://github.com/DelDongo"><img src="https:&#x2F;&#x2F;github.com&#x2F;DelDongo.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/markamos"><img src="https:&#x2F;&#x2F;github.com&#x2F;markamos.png" width="60px" alt="User avatar: Mark Amos" /></a><a href="https://github.com/dwelfusius"><img src="https:&#x2F;&#x2F;github.com&#x2F;dwelfusius.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/mews-se"><img src="https:&#x2F;&#x2F;github.com&#x2F;mews-se.png" width="60px" alt="User avatar: Martin Stockzell" /></a><a href="https://github.com/jdiegmueller"><img src="https:&#x2F;&#x2F;github.com&#x2F;jdiegmueller.png" width="60px" alt="User avatar: Jason A. Diegmueller" /></a><a href="https://github.com/robertsandrock"><img src="https:&#x2F;&#x2F;github.com&#x2F;robertsandrock.png" width="60px" alt="User avatar: RMS" /></a><a href="https://github.com/KenichiQaz"><img src="https:&#x2F;&#x2F;github.com&#x2F;KenichiQaz.png" width="60px" alt="User avatar: Stefan" /></a><a href="https://github.com/paulsheets"><img src="https:&#x2F;&#x2F;github.com&#x2F;paulsheets.png" width="60px" alt="User avatar: Paul" /></a><a href="https://github.com/djones369"><img src="https:&#x2F;&#x2F;github.com&#x2F;djones369.png" width="60px" alt="User avatar: Dave J. - WhamGeek" /></a><a href="https://github.com/anthonymendez"><img src="https:&#x2F;&#x2F;github.com&#x2F;anthonymendez.png" width="60px" alt="User avatar: Anthony Mendez" /></a><a href="https://github.com/FatBastard0"><img src="https:&#x2F;&#x2F;github.com&#x2F;FatBastard0.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/DursleyGuy"><img src="https:&#x2F;&#x2F;github.com&#x2F;DursleyGuy.png" width="60px" alt="User avatar: DursleyGuy" /></a><a href="https://github.com/realmuddy"><img src="https:&#x2F;&#x2F;github.com&#x2F;realmuddy.png" width="60px" alt="User avatar: Phillip Waters" /></a><a href="https://github.com/quaszi"><img src="https:&#x2F;&#x2F;github.com&#x2F;quaszi.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/DwayneTheRockLobster1"><img src="https:&#x2F;&#x2F;github.com&#x2F;DwayneTheRockLobster1.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/KieraKujisawa"><img src="https:&#x2F;&#x2F;github.com&#x2F;KieraKujisawa.png" width="60px" alt="User avatar: Kiera Meredith" /></a><a href="https://github.com/danhively"><img src="https:&#x2F;&#x2F;github.com&#x2F;danhively.png" width="60px" alt="User avatar: Dan Hively" /></a><!-- sponsors -->
8383

8484
## 🏅 Thanks to all Contributors
8585
Thanks a lot for spending your time helping Winutil grow. Thanks a lot! Keep rocking 🍻.

functions/public/Invoke-WPFButton.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function Invoke-WPFButton {
4545
"WPFPanelSystem" {Invoke-WPFControlPanel -Panel $button}
4646
"WPFPanelTimedate" {Invoke-WPFControlPanel -Panel $button}
4747
"WPFPanelUser" {Invoke-WPFControlPanel -Panel $button}
48-
"WPFUpdatesdefault" {Invoke-WPFFixesUpdate}
48+
"WPFUpdatesdefault" {Invoke-WPFUpdatesdefault}
4949
"WPFFixesUpdate" {Invoke-WPFFixesUpdate}
5050
"WPFFixesWinget" {Invoke-WPFFixesWinget}
5151
"WPFRunAdobeCCCleanerTool" {Invoke-WPFRunAdobeCCCleanerTool}

functions/public/Invoke-WPFUpdatesdefault.ps1

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ function Invoke-WPFUpdatesdefault {
55
Resets Windows Update settings to default
66
77
#>
8+
9+
Write-Host "Restoring Windows Update registry settings..." -ForegroundColor Yellow
10+
811
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")) {
912
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null
1013
}
@@ -15,17 +18,99 @@ function Invoke-WPFUpdatesdefault {
1518
}
1619
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -Type DWord -Value 1
1720

21+
# Reset WaaSMedicSvc registry settings to defaults
22+
Write-Host "Restoring WaaSMedicSvc settings..." -ForegroundColor Yellow
23+
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc" -Name "Start" -Type DWord -Value 3 -ErrorAction SilentlyContinue
24+
Remove-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc" -Name "FailureActions" -ErrorAction SilentlyContinue
25+
26+
# Restore update services to their default state
27+
Write-Host "Restoring update services..." -ForegroundColor Yellow
28+
1829
$services = @(
19-
"BITS"
20-
"wuauserv"
30+
@{Name = "BITS"; StartupType = "Manual"},
31+
@{Name = "wuauserv"; StartupType = "Manual"},
32+
@{Name = "UsoSvc"; StartupType = "Automatic"},
33+
@{Name = "uhssvc"; StartupType = "Disabled"},
34+
@{Name = "WaaSMedicSvc"; StartupType = "Manual"}
2135
)
2236

2337
foreach ($service in $services) {
24-
# -ErrorAction SilentlyContinue is so it doesn't write an error to stdout if a service doesn't exist
38+
try {
39+
Write-Host "Restoring $($service.Name) to $($service.StartupType)..."
40+
$serviceObj = Get-Service -Name $service.Name -ErrorAction SilentlyContinue
41+
if ($serviceObj) {
42+
Set-Service -Name $service.Name -StartupType $service.StartupType -ErrorAction SilentlyContinue
43+
44+
# Reset failure actions to default using sc command
45+
Start-Process -FilePath "sc.exe" -ArgumentList "failure `"$($service.Name)`" reset= 86400 actions= restart/60000/restart/60000/restart/60000" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
46+
47+
# Start the service if it should be running
48+
if ($service.StartupType -eq "Automatic") {
49+
Start-Service -Name $service.Name -ErrorAction SilentlyContinue
50+
}
51+
}
52+
}
53+
catch {
54+
Write-Host "Warning: Could not restore service $($service.Name) - $($_.Exception.Message)" -ForegroundColor Yellow
55+
}
56+
}
2557

26-
Write-Host "Setting $service StartupType to Automatic"
27-
Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Automatic
58+
# Restore renamed DLLs if they exist
59+
Write-Host "Restoring renamed update service DLLs..." -ForegroundColor Yellow
60+
61+
$dlls = @("WaaSMedicSvc", "wuaueng")
62+
63+
foreach ($dll in $dlls) {
64+
$dllPath = "C:\Windows\System32\$dll.dll"
65+
$backupPath = "C:\Windows\System32\${dll}_BAK.dll"
66+
67+
if ((Test-Path $backupPath) -and !(Test-Path $dllPath)) {
68+
try {
69+
# Take ownership of backup file
70+
Start-Process -FilePath "takeown.exe" -ArgumentList "/f `"$backupPath`"" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
71+
72+
# Grant full control to everyone
73+
Start-Process -FilePath "icacls.exe" -ArgumentList "`"$backupPath`" /grant *S-1-1-0:F" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
74+
75+
# Rename back to original
76+
Rename-Item -Path $backupPath -NewName "$dll.dll" -ErrorAction SilentlyContinue
77+
Write-Host "Restored ${dll}_BAK.dll to $dll.dll"
78+
79+
# Restore ownership to TrustedInstaller
80+
Start-Process -FilePath "icacls.exe" -ArgumentList "`"$dllPath`" /setowner `"NT SERVICE\TrustedInstaller`"" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
81+
Start-Process -FilePath "icacls.exe" -ArgumentList "`"$dllPath`" /remove *S-1-1-0" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
82+
}
83+
catch {
84+
Write-Host "Warning: Could not restore $dll.dll - $($_.Exception.Message)" -ForegroundColor Yellow
85+
}
86+
}
2887
}
88+
89+
# Enable update related scheduled tasks
90+
Write-Host "Enabling update related scheduled tasks..." -ForegroundColor Yellow
91+
92+
$taskPaths = @(
93+
'\Microsoft\Windows\InstallService\*'
94+
'\Microsoft\Windows\UpdateOrchestrator\*'
95+
'\Microsoft\Windows\UpdateAssistant\*'
96+
'\Microsoft\Windows\WaaSMedic\*'
97+
'\Microsoft\Windows\WindowsUpdate\*'
98+
'\Microsoft\WindowsUpdate\*'
99+
)
100+
101+
foreach ($taskPath in $taskPaths) {
102+
try {
103+
$tasks = Get-ScheduledTask -TaskPath $taskPath -ErrorAction SilentlyContinue
104+
foreach ($task in $tasks) {
105+
Enable-ScheduledTask -TaskName $task.TaskName -TaskPath $task.TaskPath -ErrorAction SilentlyContinue
106+
Write-Host "Enabled task: $($task.TaskName)"
107+
}
108+
}
109+
catch {
110+
Write-Host "Warning: Could not enable tasks in path $taskPath - $($_.Exception.Message)" -ForegroundColor Yellow
111+
}
112+
}
113+
29114
Write-Host "Enabling driver offering through Windows Update..."
30115
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -ErrorAction SilentlyContinue
31116
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontPromptForWindowsUpdate" -ErrorAction SilentlyContinue
@@ -39,6 +124,7 @@ function Invoke-WPFUpdatesdefault {
39124
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "BranchReadinessLevel" -ErrorAction SilentlyContinue
40125
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferFeatureUpdatesPeriodInDays" -ErrorAction SilentlyContinue
41126
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferQualityUpdatesPeriodInDays" -ErrorAction SilentlyContinue
127+
42128
Write-Host "==================================================="
43129
Write-Host "--- Windows Update Settings Reset to Default ---"
44130
Write-Host "==================================================="
@@ -62,4 +148,6 @@ function Invoke-WPFUpdatesdefault {
62148
Write-Host "==================================================="
63149
Write-Host "--- Windows Local Policies Reset to Default ---"
64150
Write-Host "==================================================="
151+
152+
Write-Host "Note: A system restart may be required for all changes to take full effect." -ForegroundColor Yellow
65153
}

0 commit comments

Comments
 (0)