This is not the first time I’ve encountered the Getting Windows Ready. Don’t turn off your computer
message and hangs at this stage for hours when rebooting or shutting down Windows. This problem most often occurs on Windows Server 2022, 2019, and 2016 hosts after installing Windows updates or adding/removing roles and features (but it can also happen on Windows 11 and 10).
When such a message appears, the main advice is to be patient and wait until Windows finishes installing updates and components. If you regularly install Windows updates on a computer, in rare cases, it will take more than one hour to complete the installation. If you haven’t installed updates for a long time, or your computer’s performance is poor, this installation may take several hours.
However, in some cases, the computer may get stuck on the “Preparing Windows” message for hours, days, or even indefinitely. In cases where you intentionally need to shut down or restart the computer, you can forcibly interrupt the process (Of course, there are risks to image integrity, but sometimes there is simply no choice).
Next, we’ll look at how to gracefully terminate all background processes on a computer that has frozen during update installation or image preparation.
The idea behind this method is that the computer is accessible via the network during this phase of image servicing. Although it is not possible to access the computer desktop remotely via RDP, you can connect to it remotely using administrative tools.
You will need a different Windows computer on the same local network (LAN). First, check that you can access the computer that is stuck at the “Preparing Windows” stage over the network and that the SMB port (445) is open.
Test-NetConnection 192.168.123.10 -port 445
Open the Services snap-in (services.msc
) and remotely connect to the problem host (Action -> Connect to another computer -> Specify the name or IP address of the remote server).
Find the Windows Modules Installer in the list of services. This service often gets stuck in the “Stopping” state. Obviously, this service apparently prevents Windows from rebooting or shutting down properly.
The buttons for managing the TrustedInstaller service in the snap-in GUI are not available. It cannot be stopped or paused. The name of the service executable file can be found in the service properties (it is C:\Windows\servicing\TrustedInstaller.exe
).
If you want to forcefully stop a hung service, you need to use the remote computer command prompt. For this, you can use the PsExec tool. Open the Command Prompt on your computer and run the command:
PsExec.exe \\192.168.13.10 -i -u localadminname powershell.exe
Where:
192.168.13.10
– the name or IP address of the computer to which you want to connect remotely.localadminname
– an account with administrator permissions on a remote computer (you will be prompted for a password)- If you do not specify
-u localadminname
, the current user’s credentials will be used to connect to the remote computer (convenient for a domain environment). powershell.exe
– open a PowerShell console on a remote computer
Let’s take a look at what’s on the computer. List the top 10 processes by RAM usage:
Get-Process | Sort-Object WorkingSet -Descending | Select-Object -First 10 Name, Id, @{Name="Memory (MB)"; Expression={[math]::round($_.WorkingSet / 1MB, 2)}}
then by CPU usage:
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 Name, Id, @{Name="CPU Time (s)"; Expression={[math]::round($_.CPU, 2)}}
As you can see here, the host is experiencing high resource usage from the TiWorker.exe
process. The TiWorker process (Trusted Installer Worker) is a key component of the Windows Modules Installer (TrustedInstaller
) service. This service is responsible for handling updates and Windows system components.
Check how long this process has been running:
Get-Process TiWorker | Select-Object Id, Name, CPU, WorkingSet, StartTime
Check which Windows services are stuck in the “Stopping” state:
Get-CimInstance -Class win32_service | where-Object state -eq 'stop pending'
To force-terminate the TrustedInstaller service and all related components, run the following command:
taskkill /IM TrustedInstaller.exe /F
pskill.exe \\192.168.13.10 TrustedInstaller.exe
Or, use this command when you need to specify user credentials for the connection.
taskkill.exe /s 192.168.13.10 /u woshub\admin_account /p MyPassw0rd! /im TrustedInstaller.exe
After this, the message “Shutting down” should appear on the screen of the stuck server. After a few seconds, it should reboot correctly.
It is generally not recommended to force-terminate TrustedInstaller service processes. However, if the computer remains stuck at the Windows preparation stage for an unusually long time, the only viable option may be to force a reboot or shutdown
After booting up Windows, check the integrity of the operating system image. Use DISM and SFC to find and repair any errors found:
dism.exe /online /cleanup-image /restorehealth
sfc /scannow