It is not the first time when I come across the following issue in Windows Server 2008 R2 / Windows Server 2012/R2: after the installation of updates or some roles/components, a server prompts to be restarted. Then the message “Preparing to configure Windows. Do not turn off your computer” appears and the server gets stuck for hours. However, the server is accessible, but a number of services, including RDP, are unavailable.
As a rule, in this case the easiest way to solve the problem is to perform server hard reset. For example, you can restart a physical server remotely using HP ILO, Dell iDRAC etc., or using Hyper-V / vSphere consoles (if it is a virtual machine). However, it may negatively affect the OS operation. It is better to use a more “soft” way to reset the server stuck while rebooting.
From another computer using the Services snap-in (services.msc), connect to the stuck server remotely.
In the list of services of the server, it is easy to find Windows Modules Installer in the Stopping state. Obviously, this service prevents the server from performing the correct reboot.
At the same time, the service control buttons are inactive. In the properties of the service, you can find the name of the executable: C:\Windows\servicing\TrustedInstaller.exe
Our task is to force this process to stop. The easiest way to use the script described in the article How to kill a Windows service stuck on stopping bearing in mind that you will have to do all steps remotely.
On any computer, open the command prompt and run the following command for the server called lon-man02 to stop the TrustedInstaller.exe process .
taskkill.exe /s lon-man01 /u corp\admin_name /p P@ssw0rd! /im TrustedInstaller.exe
The same can be done using Pskill from PSTools:
pskill.exe \\lon-man01 TrustedInstaller.exe
psexec \\lon-man01 taskkill /IM TrustedInstaller.exe /F
After that the message Shutting down will appear on the screen of the hung server, and in some moments it should reboot correctly.
This issue appears not only on server Windows versions, but also on client Windows 7 / Windows 8 / Windows 10.