If you have set Windows Update to automatic mode, it takes care of detecting, downloading, and installing all necessary updates – fine. However, it also automatically takes care of rebooting if required.
To turn off automatic rebooting while a user is logged on, you can use a script like this to change the appropriate Registry setting:
$key = @{ Path = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\WindowsUpdate\AU' Name = 'NoAutoRebootWithLoggedOnUsers' } Set-ItemProperty @key -Value 1 -Type DWORD
To change it back to defaults, use either one of these:
Set-ItemProperty @key -Value 0 -Type DWORD Remove-ItemProperty @key
Note that this code is a generic template and illustrates how you can set or remove any Registry value easily. Of course, you may need admin privileges to do the change, and you should know exactly what you are doing because messing up the Registry can destroy your Windows installation.