Author : Ingmar Verheij
When Microsoft Windows systems are virtualized with VMware ESX or Workstation, WMware Tools is installed. When the VMware tools are installed with the Complete option, the shared folders option is enabled. This feature is not enabled when you install VMware tools with the Typical option.
The shared folder feature is not supported by ESX or GSX server and causes problems on Terminal Servers. The file hgfs.dat is opened by the VMware Tools with exclusive acces, which prevents the profile from getting deleted.
In a terminal server environment is common to use roaming (or mandatory) profiles. To prevent the system from bloating with unused profiles, the profiles are usually removed at logoff. Since the hgfs.dat is locked, this is prevented and the server might end up with many profile folders.
In the event log the following events can be found.
Event ID 1533 Source User Profile Service Type Error Description Windows cannot delete the profile directory C:\Users\\AppData\Local\VMware\hgfs.dat. This error may be caused by files in this directory being used by another program. DETAIL - The directory is not empty.
Event ID 1000 Source Userenv Type Warning Description Windows cannot copy file C:\Users\\AppData\Local\VMware\hgfs.dat to . Contact your network administrator. DETAIL - The process cannot access the file because it is being used by another process.
The problem can be solved by disabling the Shared Folder feature in VMware Tools. This has to be configured in the registry by removing the shared folder feature from the NetworkProvider.
From VMware KB article 1317:
- Access the Windows Registry. Choose Start > Run, then type regedit. The Registry Editor window opens.
- Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order\.
- Right-click ProviderOrder and choose Modify. In the Edit String Value dialog box, edit the value data string and remove the word hgfs, vmhgs, or vmhgfs).
- If the value data string contains LanmanWorkstation,hgfs, LanmanWorkstation,vmhgs, or LanmanWorkstation,vmhgfs, change it to LanmanWorkstation.
- If the value data string contains only hgfs or vmhgfs, erase it and leave the value data string empty.
- Click OK.
- Close the registry editor. Choose File > Exit.
- Reboot the virtual machine.
Instead of editing the value per server I created a small VBscript to deploy on all Terminal Servers.
'Define variables Dim objShell Dim strProviderOrder 'Connect to subssystems Set objShell = WScript.CreateObject("WScript.Shell") 'Read registry key strProviderOrder = objShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order\ProviderOrder") 'Remove VMware Shared Folder strProviderOrder = Replace(strProviderOrder, "vmhgfs,", "", 1, -1, 1) strProviderOrder = Replace(strProviderOrder, "vmhgs,", "", 1, -1, 1) strProviderOrder = Replace(strProviderOrder, "hgfs,", "", 1, -1, 1) 'Write registry key objShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order\ProviderOrder", strProviderOrder, "REG_SZ"