When upgrading Windows stemcell to >2019.88, Apply Changes fails with:
Error: Timed out pinging VM 'compilation-xxxx-xxxx-xxx-xxx-x-pas-windows-xxxxx' with agent 'xxxxx' after 600 seconds
Error: Agent exited with error: Running bootstrap: Setting up tmp dir: Creating symlink from C:\Windows\TEMP to \var\vcap\data\tmp: Removing new path at C:\Windows\TEMP: remove C:\Windows\TEMP\vmware-vmsvc-SYSTEM.log: The process cannot access the file because it is being used by another process.
Background
With Windows Update KB5053596 present on the Windows base VM, the stricter handling of GetTempPath(2) validation required a change to stembuild handling beginning in Windows stemcell release version 2019.86 and may cause the open IPC handles from vmtoolsd.exe to prevent the relink stage of the stembuild process.
Windows Update KB5053596 (March 11, 2025) for Windows Server 2019 introduced additional kernel level hardening around file handle integrity and symbolic link creation in protected system directories such as %WINDIR%\Temp and %SystemRoot%\Installer. Prior to this update, Windows allowed rename and re-link operations on directories even when certain file handles were open. After KB5053594/6 those operations are now blocked.
As part of preparing a Windows stemcell, stembuild replaces C:\Windows\Temp with a junction pointing to the ephemeral disk; the relink step deletes the existing Temp directory and creates a new symbolic link.
With the KB5053596 handle enforcement, this operation can, under certain circumstances e.g. undetected corruption on the base VM operating system, fail if any process including background system agents, has open file handles in C:\Windows\Temp. The resulting issue presents itself as an error originating from a configuration vm and appear as the BOSH agents failure to connect to the Director.
Caveats
VMware Tools inter-process communication (IPC) artifacts hold open file handles in C:\Windows\Temp such as C:\Windows\Temp\vmware-vmusr-Administrator. VMTools is required for the stembuild construct stage of the stemcell build process and thus should not be stopped manually prior to the completion of this stage.
During the construction of a Windows stemcell, stembuild can produce a completed stemcell while still failing Apply Changes. The reason for this is because stembuild does not check Windows operating system integrity or perform any post-build stemcell sanity checks. For example corruption in Windows Update servicing stack, WinHTTP, cryptography stores, WMI, or filesystem metadata will not be detected during the stembuild process but could cause failure during BOSH bootstrap.
Option 1 (Fastest/preferred/reliable)
1. Rebuild the base VM from a licensed version of Microsoft Server 2019
2. Install all recommended Windows Updates on the new base VM
3. Kickoff a new stembuild
Option 2 (When option #1 is not possible)
1. Get the detailed list of current updates by setting your search context and writing out the results to a file for easy searching:
2. Open notepad from the command line by typing notepad:
Example output from C:\Windows\Temp\WU-out.txt:
3. Kickoff a new stembuild
If Option 2 is used prior to Option 1, and the BOSH agent is still failing bootstrap, it likely means that the base OS is corrupt. This can happen for a variety of reasons that the stembuild process will not catch. In that case, Option 1 will need to be used.