@@ -9,28 +9,28 @@ function Invoke-WPFUpdatesdisable {
99 This function requires administrator privileges and will attempt to run as SYSTEM for certain operations.
1010
1111 #>
12-
12+
1313 Write-Host " Configuring registry settings..." - ForegroundColor Yellow
14-
14+
1515 If (! (Test-Path " HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" )) {
1616 New-Item - Path " HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" - Force | Out-Null
1717 }
1818 Set-ItemProperty - Path " HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" - Name " NoAutoUpdate" - Type DWord - Value 1
1919 Set-ItemProperty - Path " HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" - Name " AUOptions" - Type DWord - Value 1
20-
20+
2121 If (! (Test-Path " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" )) {
2222 New-Item - Path " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" - Force | Out-Null
2323 }
2424 Set-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" - Name " DODownloadMode" - Type DWord - Value 0
25-
25+
2626 # Additional registry settings
2727 Set-ItemProperty - Path " HKLM:\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc" - Name " Start" - Type DWord - Value 4 - ErrorAction SilentlyContinue
2828 $failureActions = [byte []](0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0x14 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xc0 , 0xd4 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xe0 , 0x93 , 0x04 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 )
2929 Set-ItemProperty - Path " HKLM:\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc" - Name " FailureActions" - Type Binary - Value $failureActions - ErrorAction SilentlyContinue
3030
3131 # Disable and stop update related services
3232 Write-Host " Disabling update services..." - ForegroundColor Yellow
33-
33+
3434 $services = @ (
3535 " BITS"
3636 " wuauserv"
@@ -46,7 +46,7 @@ function Invoke-WPFUpdatesdisable {
4646 if ($serviceObj ) {
4747 Stop-Service - Name $service - Force - ErrorAction SilentlyContinue
4848 Set-Service - Name $service - StartupType Disabled - ErrorAction SilentlyContinue
49-
49+
5050 # Set failure actions to nothing using sc command
5151 Start-Process - FilePath " sc.exe" - ArgumentList " failure `" $service `" reset= 0 actions= `"`" " - Wait - WindowStyle Hidden - ErrorAction SilentlyContinue
5252 }
@@ -58,26 +58,26 @@ function Invoke-WPFUpdatesdisable {
5858
5959 # Rename critical update service DLLs (requires SYSTEM privileges)
6060 Write-Host " Attempting to rename critical update service DLLs..." - ForegroundColor Yellow
61-
61+
6262 $dlls = @ (" WaaSMedicSvc" , " wuaueng" )
63-
63+
6464 foreach ($dll in $dlls ) {
6565 $dllPath = " C:\Windows\System32\$dll .dll"
6666 $backupPath = " C:\Windows\System32\${dll} _BAK.dll"
67-
67+
6868 if (Test-Path $dllPath ) {
6969 try {
7070 # Take ownership
7171 Start-Process - FilePath " takeown.exe" - ArgumentList " /f `" $dllPath `" " - Wait - WindowStyle Hidden - ErrorAction SilentlyContinue
72-
72+
7373 # Grant full control to everyone
7474 Start-Process - FilePath " icacls.exe" - ArgumentList " `" $dllPath `" /grant *S-1-1-0:F" - Wait - WindowStyle Hidden - ErrorAction SilentlyContinue
75-
75+
7676 # Rename file
7777 if (! (Test-Path $backupPath )) {
7878 Rename-Item - Path $dllPath - NewName " ${dll} _BAK.dll" - ErrorAction SilentlyContinue
7979 Write-Host " Renamed $dll .dll to ${dll} _BAK.dll"
80-
80+
8181 # Restore ownership to TrustedInstaller
8282 Start-Process - FilePath " icacls.exe" - ArgumentList " `" $backupPath `" /setowner `" NT SERVICE\TrustedInstaller`" " - Wait - WindowStyle Hidden - ErrorAction SilentlyContinue
8383 Start-Process - FilePath " icacls.exe" - ArgumentList " `" $backupPath `" /remove *S-1-1-0" - Wait - WindowStyle Hidden - ErrorAction SilentlyContinue
@@ -91,7 +91,7 @@ function Invoke-WPFUpdatesdisable {
9191
9292 # Delete downloaded update files
9393 Write-Host " Cleaning up downloaded update files..." - ForegroundColor Yellow
94-
94+
9595 try {
9696 $softwareDistPath = " C:\Windows\SoftwareDistribution"
9797 if (Test-Path $softwareDistPath ) {
@@ -105,7 +105,7 @@ function Invoke-WPFUpdatesdisable {
105105
106106 # Disable update related scheduled tasks
107107 Write-Host " Disabling update related scheduled tasks..." - ForegroundColor Yellow
108-
108+
109109 $taskPaths = @ (
110110 ' \Microsoft\Windows\InstallService\*'
111111 ' \Microsoft\Windows\UpdateOrchestrator\*'
@@ -129,7 +129,7 @@ function Invoke-WPFUpdatesdisable {
129129 }
130130
131131 Write-Host " =================================" - ForegroundColor Green
132- Write-Host " --- Updates ARE DISABLED ---" - ForegroundColor Green
132+ Write-Host " --- Updates ARE DISABLED ---" - ForegroundColor Green
133133 Write-Host " ===================================" - ForegroundColor Green
134134 Write-Host " Note: Some operations may require a system restart to take full effect." - ForegroundColor Yellow
135135}
0 commit comments