A Simple PowerShell Script that once ran will prevent windows update from every rebooting your PC again automatically.
- Download the script
- Right click the script and select "Run with Powershell"
- When prompted, click "Yes" to run the script with administrator privileges
- Give Windows Update the finger, you have finally defeated it.
- Download the script
- Open a PowerShell window with administrator privileges
- Navigate to the directory where the script is located
- Run the script with the following command:
powershell -ExecutionPolicy Bypass -File FWindowsUpdateReboot.ps1
- Give Windows Update the finger, you have finally defeated it.
- Open a PowerShell window with administrator privileges
- Run the following command:
FWindowsUpdateReboot -Uninstall
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. You are limited to 18 hours for Active Hours, and if you are outside of that, you will be rebooted. The script works by to permanently prevent Windows Update from restarting your PC by continuously rotating your Windows Active Hours every hour so you're never outside of Active Hours.
- If not run with administrator privileges, the script will request elevation to run as administrator.
- The script will then:
- Copy itself to the Windows System32 directory
- Create a scheduled task called "FWindowsUpdateReboot" that runs every hour
- The scheduled task runs the script with the -Rotate parameter, which:
- Sets Active Hours to start at the current hour
- Sets Active Hours to end 18 hours later (the maximum allowed duration)
- Updates these settings in the Windows registry
By dynamically adjusting Active Hours every hour, you are never outside of Active Hours, and Windows Update will never find a suitable time outside of Active Hours to restart your computer.
The script runs silently in the background using minimal resources.
For example, if you're using your PC at 2 PM:
- Active Hours will be set to 2 PM - 8 AM
- An hour later at 3 PM, they'll adjust to 3 PM - 9 AM
- This continues as long as your PC is running
The script requires a one-time setup with administrator privileges, but then runs automatically as a system service requiring no further interaction.
Before running any PowerShell script downloaded from the internet (including this one), you should always review its contents to ensure it's safe. While this script is open source and safe to use, it's good security practice to verify scripts before executing them with administrator privileges.
The full source code is available in this repository for transparency and security verification.
Review the script source code to ensure it's safe:
FWindowsUpdateReboot/FWindowsUpdateReboot.ps1
Lines 1 to 153 in 4eeee1f
The project includes unit tests written using Pester, the standard testing framework for PowerShell. Tests can be run locally or through GitHub Actions CI pipeline.
- Clone the repository:
git clone https://github.com/cboileau/FWindowsUpdateReboot.git
cd FWindowsUpdateReboot
You can also run specific test categories from PowerShell:
# Run all tests
.\Run-Tests.ps1 -TestType All
# Run only installation tests
.\Run-Tests.ps1 -TestType Installation
# Run only active hours tests
.\Run-Tests.ps1 -TestType ActiveHours
# Run only uninstallation tests
.\Run-Tests.ps1 -TestType Uninstallation
The project uses GitHub Actions to run tests automatically on:
- Every push to the main branch
- Every pull request to the main branch
Test results can be viewed in the Actions tab of the repository.
To run specific test cases, you can use Pester's filtering:
# Run only installation tests
$config = New-PesterConfiguration
$config.Filter.Tag = "Installation"
$config.Run.Path = "Tests"
Invoke-Pester -Configuration $config
# Run only active hours tests
$config = New-PesterConfiguration
$config.Filter.Tag = "ActiveHours"
$config.Run.Path = "Tests"
Invoke-Pester -Configuration $config
If tests fail, check:
- Pester is installed correctly
- You're in the correct directory
- Your PowerShell execution policy allows running scripts