Microsoft Windows - Install Updates And Restart (instead of Install and Shutdown)
Solution 1:
Yes. You can install all of the updates available - via either Windows Update in your Control Panel, or the yellow WU shield in the system tray near the clock. Then, when that's done, you can do a reboot from the Start Menu (or calling shutdown /r from the command line.)
The only other ways to automate it all in one step is via writing your own code (not just a simple script), or using add-on tools, free or commercial, from either MS or 3rd parties.
Solution 2:
There are certain benefits to installing updates during rebooting/shut-down:
The installation is not slowed down, or tampered with by other running software, AVP, etc.
There's no UI to deal with, click through, etc. It goes through faster. When it's done, in case of a reboot, the computer is ready to go.
Unfortunately there seems to be no way to do it with Microsoft provided tools. I use this free utility that will do it for you. I created a shortcut with the following parameters and placed it into my Start button menu:
ShutdownWithUpdates /r /f
From what I see it can also reboot and install updates on a remote workstation in an active directory setup.
Read more here.
Solution 3:
I see this is an older question, but it's now possible to install updates and then reboot using Powershell. Specifically, you need to download and install the Windows Update PowerShell Module. Then, you can run the command Get-WUInstall -AcceptAll -AutoReboot
(there are other switches and arguments to control what updates get installed). This will cause Windows to download updates, install them, and then reboot when finished. In my opinion, this is great for servers, because you can run one command and then walk away.
Solution 4:
There is no way to initate a "Install Updates and Restart" manually. You could set a time for the updates to install, and then specify that the machine can reboot after Automatic Updates, either via the Automatic Updates (or Windows Update) control panel, directly via the registry, or via Group Policy:
http://support.microsoft.com/kb/328010
But as far as a one-click "Install updates and reboot" option, there is none.
Solution 5:
This shows up high on the "Install and Restart not Install and Shutdown" Google search. Hence, I thought I should add a solution that I ended up writing for this exact annoying problem (people tell me that Win10 has this by default, but I am not on Win10).
This works using two batch files. The first one is called "rebootAfterUpdates.bat"
@echo OFF
@setlocal ENABLEEXTENSIONS
@set REBOOT_KEY="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired"
@SET REGDWORD=REG_DWORD
@SET VALUEVAL=0x1
@REM skip=4 may be required on some versions of Windows
@FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`reg query %REBOOT_KEY% /s 2^>nul`) DO (
@IF %%B EQU %REGDWORD% (
@IF %%C EQU %VALUEVAL% (
call :REBOOT
)
)
)
:NOREBOOT
@Echo No reboot required
exit /b 36877
REM 36877 is 0x900D (i.e. Good, no reboot required)
:REBOOT
@ECHO Here We REBOOT
SHUTDOWN -r -f -t 10
exit /b 3059719
REM 3059719 is 0x2EB007 (i.e. REBOOT was triggered)
The second one is called "scheduleRebootAfterUpdates.bat":
@schtasks /query /TN RebootAfterUpdates > doh
@findstr /B /I "RebootAfterUpdates" doh >nul
@if %errorlevel%==0 goto :update
@goto :create
:update
@del doh
@SCHTASKS /Change /TN RebootAfterUpdates /SD %DATE%
@echo Task updated to execute today
@goto :exitBat
:create
@del doh
@SCHTASKS /Create /SC ONCE /TN RebootAfterUpdates /TR "C:\tmp\Scripts\rebootAfterUpdates.bat" /ST 23:55 /sd %DATE% /ru SYSTEM /f
@echo Task created. Set the "Wake to Execute Flag" through Task Scheduler GUI
:exitBat
@exit /b
Both files are assumed to be in C:\tmp\Scripts\ When Windows nags you to "Install Updates", let it start installing updates. While it installs updates, run "scheduleRebootAfterUpdates.bat".
Background of operation:
If the updates require a reboot, some registry keys (under the WindowsUpdate reg key) are set with value 0x1.
We check if these keys exist in the first bat file. If they do, reboot right away.
Normally, I trigger updates when about to leave work (and about 4-5 hours before midnight).
The second bat creates a scheduled task (or updates an existing task to run 5 min before midnight) and this scheduled task executes the first bat.
So... while not the most elegant solution, in two steps (1. trigger 'Install Updates' and 2. run the second bat file), your machine will reboot near midnight assuming that installation of updates succeeded.
Additionally, you can set the 'Wake machine to execute task' from the Task Scheduler GUI as well as check the execution return code to see what happened last time.
P.S. Tested on Win7 64bit.