Registry Method
Open Registry Editor and create a DWORD called NoAutoRebootWithLoggedOnUsers under HKEY_LOCAL_MACHINE, SOFTWARE, Policies, Microsoft, Windows, WindowsUpdate and finally AU. The value of NoAutoRebootWithLoggedOnUsers must be set to 1 to enable and 0 to disable.
Group Policy Method
Open Group Policy editor and navigate through Local Computer Policy, Computer Configuration, Administrative Templates, Windows Components and Windows Update.
Locate “No auto-restart with logged on users for scheduled automatic updates installations” and right click on it and select Edit.
Select Enabled and click OK.