mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-09-05 10:45:47 -05:00
Compare commits
1 Commits
25.09.05
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
4cd3d2657f |
@ -9,7 +9,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Check if PR was merged
|
||||
if: github.event.pull_request.merged == true
|
||||
|
2
.github/workflows/compile-check.yaml
vendored
2
.github/workflows/compile-check.yaml
vendored
@ -13,7 +13,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout Sources
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Compile and Syntaxcheck winutil.ps1
|
||||
shell: pwsh
|
||||
|
2
.github/workflows/pre-release.yaml
vendored
2
.github/workflows/pre-release.yaml
vendored
@ -14,7 +14,7 @@ jobs:
|
||||
CERTIFICATE_BASE64: ${{ secrets.CERTIFICATE_BASE64 }}
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Compile project
|
||||
shell: pwsh
|
||||
|
2
.github/workflows/remove-winutil.yaml
vendored
2
.github/workflows/remove-winutil.yaml
vendored
@ -11,7 +11,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Check if winutil.ps1 exists
|
||||
id: check_existence
|
||||
|
2
.github/workflows/sponsors.yaml
vendored
2
.github/workflows/sponsors.yaml
vendored
@ -11,7 +11,7 @@ jobs:
|
||||
if: (github.event_name == 'schedule' && github.repository == 'ChrisTitusTech/winutil') || (github.event_name != 'schedule')
|
||||
steps:
|
||||
- name: Checkout 🛎️
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Generate Sponsors 💖
|
||||
uses: JamesIves/github-sponsors-readme-action@v1
|
||||
|
4
.github/workflows/unittests.yaml
vendored
4
.github/workflows/unittests.yaml
vendored
@ -8,7 +8,7 @@ jobs:
|
||||
name: PS Script Analyzer
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: lint
|
||||
uses: devblackops/github-action-psscriptanalyzer@master
|
||||
with:
|
||||
@ -22,7 +22,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Install Pester
|
||||
run: |
|
||||
|
@ -79,7 +79,7 @@ You'll see a new file named `winutil.ps1`, which's created by `Compile.ps1` scri
|
||||
|
||||
These are the sponsors that help keep this project alive with monthly contributions.
|
||||
|
||||
<!-- sponsors --><a href="https://github.com/TriHydera"><img src="https://github.com/TriHydera.png" width="60px" alt="User avatar: TriHydera" /></a><a href="https://github.com/DelDongo"><img src="https://github.com/DelDongo.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/markamos"><img src="https://github.com/markamos.png" width="60px" alt="User avatar: Mark Amos" /></a><a href="https://github.com/dwelfusius"><img src="https://github.com/dwelfusius.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/mews-se"><img src="https://github.com/mews-se.png" width="60px" alt="User avatar: Martin Stockzell" /></a><a href="https://github.com/jdiegmueller"><img src="https://github.com/jdiegmueller.png" width="60px" alt="User avatar: Jason A. Diegmueller" /></a><a href="https://github.com/robertsandrock"><img src="https://github.com/robertsandrock.png" width="60px" alt="User avatar: RMS" /></a><a href="https://github.com/KenichiQaz"><img src="https://github.com/KenichiQaz.png" width="60px" alt="User avatar: Stefan" /></a><a href="https://github.com/paulsheets"><img src="https://github.com/paulsheets.png" width="60px" alt="User avatar: Paul" /></a><a href="https://github.com/djones369"><img src="https://github.com/djones369.png" width="60px" alt="User avatar: Dave J. - WhamGeek" /></a><a href="https://github.com/anthonymendez"><img src="https://github.com/anthonymendez.png" width="60px" alt="User avatar: Anthony Mendez" /></a><a href="https://github.com/FatBastard0"><img src="https://github.com/FatBastard0.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/DursleyGuy"><img src="https://github.com/DursleyGuy.png" width="60px" alt="User avatar: DursleyGuy" /></a><a href="https://github.com/realmuddy"><img src="https://github.com/realmuddy.png" width="60px" alt="User avatar: Phillip Waters" /></a><a href="https://github.com/quaszi"><img src="https://github.com/quaszi.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/DwayneTheRockLobster1"><img src="https://github.com/DwayneTheRockLobster1.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/KieraKujisawa"><img src="https://github.com/KieraKujisawa.png" width="60px" alt="User avatar: Kiera Meredith" /></a><a href="https://github.com/danhively"><img src="https://github.com/danhively.png" width="60px" alt="User avatar: Dan Hively" /></a><!-- sponsors -->
|
||||
<!-- sponsors --><a href="https://github.com/TriHydera"><img src="https://github.com/TriHydera.png" width="60px" alt="User avatar: TriHydera" /></a><a href="https://github.com/DelDongo"><img src="https://github.com/DelDongo.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/markamos"><img src="https://github.com/markamos.png" width="60px" alt="User avatar: Mark Amos" /></a><a href="https://github.com/dwelfusius"><img src="https://github.com/dwelfusius.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/mews-se"><img src="https://github.com/mews-se.png" width="60px" alt="User avatar: Martin Stockzell" /></a><a href="https://github.com/jdiegmueller"><img src="https://github.com/jdiegmueller.png" width="60px" alt="User avatar: Jason A. Diegmueller" /></a><a href="https://github.com/robertsandrock"><img src="https://github.com/robertsandrock.png" width="60px" alt="User avatar: RMS" /></a><a href="https://github.com/KenichiQaz"><img src="https://github.com/KenichiQaz.png" width="60px" alt="User avatar: Stefan" /></a><a href="https://github.com/paulsheets"><img src="https://github.com/paulsheets.png" width="60px" alt="User avatar: Paul" /></a><a href="https://github.com/djones369"><img src="https://github.com/djones369.png" width="60px" alt="User avatar: Dave J. - WhamGeek" /></a><a href="https://github.com/anthonymendez"><img src="https://github.com/anthonymendez.png" width="60px" alt="User avatar: Anthony Mendez" /></a><a href="https://github.com/FatBastard0"><img src="https://github.com/FatBastard0.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/DursleyGuy"><img src="https://github.com/DursleyGuy.png" width="60px" alt="User avatar: DursleyGuy" /></a><a href="https://github.com/realmuddy"><img src="https://github.com/realmuddy.png" width="60px" alt="User avatar: Phillip Waters" /></a><a href="https://github.com/quaszi"><img src="https://github.com/quaszi.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/DwayneTheRockLobster1"><img src="https://github.com/DwayneTheRockLobster1.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/KieraKujisawa"><img src="https://github.com/KieraKujisawa.png" width="60px" alt="User avatar: Kiera Meredith" /></a><a href="https://github.com/danhively"><img src="https://github.com/danhively.png" width="60px" alt="User avatar: Dan Hively" /></a><a href="https://github.com/Yamil-Serrano"><img src="https://github.com/Yamil-Serrano.png" width="60px" alt="User avatar: Neowizen" /></a><!-- sponsors -->
|
||||
|
||||
## 🏅 Thanks to all Contributors
|
||||
Thanks a lot for spending your time helping Winutil grow. Thanks a lot! Keep rocking 🍻.
|
||||
|
@ -52,10 +52,7 @@ function Install-WinUtilWinget {
|
||||
|
||||
# Check if Windows version supports Repair-WinGetPackageManager (24H2 and above)
|
||||
if ([System.Environment]::OSVersion.Version.Build -ge 26100) {
|
||||
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
|
||||
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
|
||||
Install-Module "Microsoft.WinGet.Client" -Force
|
||||
Import-Module Microsoft.WinGet.Client
|
||||
Install-Module -Name Microsoft.WinGet.Client -Force -ErrorAction Continue
|
||||
Repair-WinGetPackageManager -Force -Latest -Verbose
|
||||
# Verify if repair was successful
|
||||
$wingetCmd = Get-Command winget -ErrorAction Stop
|
||||
|
@ -5,9 +5,6 @@ function Invoke-WPFUpdatesdefault {
|
||||
Resets Windows Update settings to default
|
||||
|
||||
#>
|
||||
|
||||
Write-Host "Restoring Windows Update registry settings..." -ForegroundColor Yellow
|
||||
|
||||
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")) {
|
||||
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null
|
||||
}
|
||||
@ -18,99 +15,17 @@ function Invoke-WPFUpdatesdefault {
|
||||
}
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -Type DWord -Value 1
|
||||
|
||||
# Reset WaaSMedicSvc registry settings to defaults
|
||||
Write-Host "Restoring WaaSMedicSvc settings..." -ForegroundColor Yellow
|
||||
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc" -Name "Start" -Type DWord -Value 3 -ErrorAction SilentlyContinue
|
||||
Remove-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc" -Name "FailureActions" -ErrorAction SilentlyContinue
|
||||
|
||||
# Restore update services to their default state
|
||||
Write-Host "Restoring update services..." -ForegroundColor Yellow
|
||||
|
||||
$services = @(
|
||||
@{Name = "BITS"; StartupType = "Manual"},
|
||||
@{Name = "wuauserv"; StartupType = "Manual"},
|
||||
@{Name = "UsoSvc"; StartupType = "Automatic"},
|
||||
@{Name = "uhssvc"; StartupType = "Disabled"},
|
||||
@{Name = "WaaSMedicSvc"; StartupType = "Manual"}
|
||||
"BITS"
|
||||
"wuauserv"
|
||||
)
|
||||
|
||||
foreach ($service in $services) {
|
||||
try {
|
||||
Write-Host "Restoring $($service.Name) to $($service.StartupType)..."
|
||||
$serviceObj = Get-Service -Name $service.Name -ErrorAction SilentlyContinue
|
||||
if ($serviceObj) {
|
||||
Set-Service -Name $service.Name -StartupType $service.StartupType -ErrorAction SilentlyContinue
|
||||
|
||||
# Reset failure actions to default using sc command
|
||||
Start-Process -FilePath "sc.exe" -ArgumentList "failure `"$($service.Name)`" reset= 86400 actions= restart/60000/restart/60000/restart/60000" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
|
||||
|
||||
# Start the service if it should be running
|
||||
if ($service.StartupType -eq "Automatic") {
|
||||
Start-Service -Name $service.Name -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "Warning: Could not restore service $($service.Name) - $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
# -ErrorAction SilentlyContinue is so it doesn't write an error to stdout if a service doesn't exist
|
||||
|
||||
Write-Host "Setting $service StartupType to Automatic"
|
||||
Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Automatic
|
||||
}
|
||||
|
||||
# Restore renamed DLLs if they exist
|
||||
Write-Host "Restoring renamed update service DLLs..." -ForegroundColor Yellow
|
||||
|
||||
$dlls = @("WaaSMedicSvc", "wuaueng")
|
||||
|
||||
foreach ($dll in $dlls) {
|
||||
$dllPath = "C:\Windows\System32\$dll.dll"
|
||||
$backupPath = "C:\Windows\System32\${dll}_BAK.dll"
|
||||
|
||||
if ((Test-Path $backupPath) -and !(Test-Path $dllPath)) {
|
||||
try {
|
||||
# Take ownership of backup file
|
||||
Start-Process -FilePath "takeown.exe" -ArgumentList "/f `"$backupPath`"" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
|
||||
|
||||
# Grant full control to everyone
|
||||
Start-Process -FilePath "icacls.exe" -ArgumentList "`"$backupPath`" /grant *S-1-1-0:F" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
|
||||
|
||||
# Rename back to original
|
||||
Rename-Item -Path $backupPath -NewName "$dll.dll" -ErrorAction SilentlyContinue
|
||||
Write-Host "Restored ${dll}_BAK.dll to $dll.dll"
|
||||
|
||||
# Restore ownership to TrustedInstaller
|
||||
Start-Process -FilePath "icacls.exe" -ArgumentList "`"$dllPath`" /setowner `"NT SERVICE\TrustedInstaller`"" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
|
||||
Start-Process -FilePath "icacls.exe" -ArgumentList "`"$dllPath`" /remove *S-1-1-0" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
|
||||
}
|
||||
catch {
|
||||
Write-Host "Warning: Could not restore $dll.dll - $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Enable update related scheduled tasks
|
||||
Write-Host "Enabling update related scheduled tasks..." -ForegroundColor Yellow
|
||||
|
||||
$taskPaths = @(
|
||||
'\Microsoft\Windows\InstallService\*'
|
||||
'\Microsoft\Windows\UpdateOrchestrator\*'
|
||||
'\Microsoft\Windows\UpdateAssistant\*'
|
||||
'\Microsoft\Windows\WaaSMedic\*'
|
||||
'\Microsoft\Windows\WindowsUpdate\*'
|
||||
'\Microsoft\WindowsUpdate\*'
|
||||
)
|
||||
|
||||
foreach ($taskPath in $taskPaths) {
|
||||
try {
|
||||
$tasks = Get-ScheduledTask -TaskPath $taskPath -ErrorAction SilentlyContinue
|
||||
foreach ($task in $tasks) {
|
||||
Enable-ScheduledTask -TaskName $task.TaskName -TaskPath $task.TaskPath -ErrorAction SilentlyContinue
|
||||
Write-Host "Enabled task: $($task.TaskName)"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "Warning: Could not enable tasks in path $taskPath - $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Enabling driver offering through Windows Update..."
|
||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -ErrorAction SilentlyContinue
|
||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontPromptForWindowsUpdate" -ErrorAction SilentlyContinue
|
||||
@ -124,7 +39,6 @@ function Invoke-WPFUpdatesdefault {
|
||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "BranchReadinessLevel" -ErrorAction SilentlyContinue
|
||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferFeatureUpdatesPeriodInDays" -ErrorAction SilentlyContinue
|
||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferQualityUpdatesPeriodInDays" -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host "==================================================="
|
||||
Write-Host "--- Windows Update Settings Reset to Default ---"
|
||||
Write-Host "==================================================="
|
||||
@ -148,6 +62,4 @@ function Invoke-WPFUpdatesdefault {
|
||||
Write-Host "==================================================="
|
||||
Write-Host "--- Windows Local Policies Reset to Default ---"
|
||||
Write-Host "==================================================="
|
||||
|
||||
Write-Host "Note: A system restart may be required for all changes to take full effect." -ForegroundColor Yellow
|
||||
}
|
||||
|
@ -6,130 +6,30 @@ function Invoke-WPFUpdatesdisable {
|
||||
|
||||
.NOTES
|
||||
Disabling Windows Update is not recommended. This is only for advanced users who know what they are doing.
|
||||
This function requires administrator privileges and will attempt to run as SYSTEM for certain operations.
|
||||
|
||||
#>
|
||||
|
||||
Write-Host "Configuring registry settings..." -ForegroundColor Yellow
|
||||
|
||||
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")) {
|
||||
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null
|
||||
}
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoUpdate" -Type DWord -Value 1
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUOptions" -Type DWord -Value 1
|
||||
|
||||
If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config")) {
|
||||
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Force | Out-Null
|
||||
}
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -Type DWord -Value 0
|
||||
|
||||
# Additional registry settings
|
||||
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc" -Name "Start" -Type DWord -Value 4 -ErrorAction SilentlyContinue
|
||||
$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)
|
||||
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc" -Name "FailureActions" -Type Binary -Value $failureActions -ErrorAction SilentlyContinue
|
||||
|
||||
# Disable and stop update related services
|
||||
Write-Host "Disabling update services..." -ForegroundColor Yellow
|
||||
|
||||
$services = @(
|
||||
"BITS"
|
||||
"wuauserv"
|
||||
"UsoSvc"
|
||||
"uhssvc"
|
||||
"WaaSMedicSvc"
|
||||
)
|
||||
|
||||
foreach ($service in $services) {
|
||||
try {
|
||||
Write-Host "Stopping and disabling $service..."
|
||||
$serviceObj = Get-Service -Name $service -ErrorAction SilentlyContinue
|
||||
if ($serviceObj) {
|
||||
Stop-Service -Name $service -Force -ErrorAction SilentlyContinue
|
||||
Set-Service -Name $service -StartupType Disabled -ErrorAction SilentlyContinue
|
||||
|
||||
# Set failure actions to nothing using sc command
|
||||
Start-Process -FilePath "sc.exe" -ArgumentList "failure `"$service`" reset= 0 actions= `"`"" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "Warning: Could not process service $service - $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
# -ErrorAction SilentlyContinue is so it doesn't write an error to stdout if a service doesn't exist
|
||||
|
||||
# Rename critical update service DLLs (requires SYSTEM privileges)
|
||||
Write-Host "Attempting to rename critical update service DLLs..." -ForegroundColor Yellow
|
||||
|
||||
$dlls = @("WaaSMedicSvc", "wuaueng")
|
||||
|
||||
foreach ($dll in $dlls) {
|
||||
$dllPath = "C:\Windows\System32\$dll.dll"
|
||||
$backupPath = "C:\Windows\System32\${dll}_BAK.dll"
|
||||
|
||||
if (Test-Path $dllPath) {
|
||||
try {
|
||||
# Take ownership
|
||||
Start-Process -FilePath "takeown.exe" -ArgumentList "/f `"$dllPath`"" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
|
||||
|
||||
# Grant full control to everyone
|
||||
Start-Process -FilePath "icacls.exe" -ArgumentList "`"$dllPath`" /grant *S-1-1-0:F" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
|
||||
|
||||
# Rename file
|
||||
if (!(Test-Path $backupPath)) {
|
||||
Rename-Item -Path $dllPath -NewName "${dll}_BAK.dll" -ErrorAction SilentlyContinue
|
||||
Write-Host "Renamed $dll.dll to ${dll}_BAK.dll"
|
||||
|
||||
# Restore ownership to TrustedInstaller
|
||||
Start-Process -FilePath "icacls.exe" -ArgumentList "`"$backupPath`" /setowner `"NT SERVICE\TrustedInstaller`"" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
|
||||
Start-Process -FilePath "icacls.exe" -ArgumentList "`"$backupPath`" /remove *S-1-1-0" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "Warning: Could not rename $dll.dll - $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
Write-Host "Setting $service StartupType to Disabled"
|
||||
Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Disabled
|
||||
}
|
||||
|
||||
# Delete downloaded update files
|
||||
Write-Host "Cleaning up downloaded update files..." -ForegroundColor Yellow
|
||||
|
||||
try {
|
||||
$softwareDistPath = "C:\Windows\SoftwareDistribution"
|
||||
if (Test-Path $softwareDistPath) {
|
||||
Get-ChildItem -Path $softwareDistPath -Recurse -Force | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
|
||||
Write-Host "Cleared SoftwareDistribution folder"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "Warning: Could not fully clear SoftwareDistribution folder - $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Disable update related scheduled tasks
|
||||
Write-Host "Disabling update related scheduled tasks..." -ForegroundColor Yellow
|
||||
|
||||
$taskPaths = @(
|
||||
'\Microsoft\Windows\InstallService\*'
|
||||
'\Microsoft\Windows\UpdateOrchestrator\*'
|
||||
'\Microsoft\Windows\UpdateAssistant\*'
|
||||
'\Microsoft\Windows\WaaSMedic\*'
|
||||
'\Microsoft\Windows\WindowsUpdate\*'
|
||||
'\Microsoft\WindowsUpdate\*'
|
||||
)
|
||||
|
||||
foreach ($taskPath in $taskPaths) {
|
||||
try {
|
||||
$tasks = Get-ScheduledTask -TaskPath $taskPath -ErrorAction SilentlyContinue
|
||||
foreach ($task in $tasks) {
|
||||
Disable-ScheduledTask -TaskName $task.TaskName -TaskPath $task.TaskPath -ErrorAction SilentlyContinue
|
||||
Write-Host "Disabled task: $($task.TaskName)"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "Warning: Could not disable tasks in path $taskPath - $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "=================================" -ForegroundColor Green
|
||||
Write-Host "--- Updates ARE DISABLED ---" -ForegroundColor Green
|
||||
Write-Host "===================================" -ForegroundColor Green
|
||||
Write-Host "Note: Some operations may require a system restart to take full effect." -ForegroundColor Yellow
|
||||
Write-Host "================================="
|
||||
Write-Host "--- Updates ARE DISABLED ---"
|
||||
Write-Host "================================="
|
||||
}
|
||||
|
Reference in New Issue
Block a user