diff --git a/FWindowsUpdateReboot.ps1 b/FWindowsUpdateReboot.ps1 index 3ff3c2c..eb53655 100644 --- a/FWindowsUpdateReboot.ps1 +++ b/FWindowsUpdateReboot.ps1 @@ -33,12 +33,11 @@ $sourceScriptPath = $MyInvocation.MyCommand.Path if ($Uninstall) { # Remove the scheduled task if it exists try { - Get-ScheduledTask -TaskName $taskName -ErrorAction Stop + $task = Get-ScheduledTask -TaskName $taskName -ErrorAction Stop Unregister-ScheduledTask -TaskName $taskName -Confirm:$false Write-Host "Scheduled task '$taskName' has been removed." } catch { - Write-Host "Error removing scheduled task: $_" - Write-Host "Scheduled task '$taskName' does not exist." + Write-Host "Scheduled task '$taskName' does not exist. (Skipping)" } # Prompt user about script removal @@ -48,10 +47,10 @@ if ($Uninstall) { Remove-Item -Path $destinationPath -Force Write-Host "Script removed from System32." } else { - Write-Host "Script not found in System32." + Write-Host "Script not found in System32. (Skipping)" } } - Write-Host "Successfully uninstalled $taskName. Press Enter to exit..." + Write-Host "Successfully uninstalled $taskName.`nPress Enter to exit..." $null = Read-Host exit } @@ -72,6 +71,7 @@ if ($Rotate) { Write-Host "Active hours updated: Start=$newActiveHoursStart, End=$newActiveHoursEnd" } else { + # Install the script # Copy the script to System32 if it's not already there if ($sourceScriptPath -ieq $destinationPath) { Write-Host "Script is already in System32." diff --git a/README.md b/README.md index f94f94a..d550f18 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,11 @@ A Simple PowerShell Script that once ran will prevent windows update from every 4. Run the script with the following command: `powershell -ExecutionPolicy Bypass -File FWindowsUpdateReboot.ps1` 5. Give Windows Update the finger, you have finally defeated it. +## How to uninstall + +1. Open a PowerShell window with administrator privileges +2. Run the following command: `FWindowsUpdateReboot -Uninstall` + ## How does it get around Windows Update restarting your PC? Windows Update forces you to reboot your PC to install updates, however it won't do so if the current time is within your Active Hours.