VMware shared folders keep profiles in use

Written by Ingmar Verheij on August 1st, 2011. Posted in Remote Desktop / Terminal Server

VMware Shared Folders

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.

Documents and Settings

Local Settings - Application Data - VMware - hgfs.dat


Event Log

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:

  1. Access the Windows Registry. Choose Start > Run, then type regedit. The Registry Editor window opens.
  2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order\.
  3. 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.
  4. Click OK.
  5. Close the registry editor. Choose File > Exit.
  6. Reboot the virtual machine.

Network Provider Order - Before

Network Provider Order - Edit

Network Provider Order - After

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"

Ingmar Verheij

At the time Ingmar wrote this article he worked for PepperByte as a Senior Consultant (up to May 2014). His work consisted of designing, migrating and troubleshooting Microsoft and Citrix infrastructures. He was working with technologies like Microsoft RDS, user environment management and (performance) monitoring. Ingmar is User Group leader of the Dutch Citrix User Group (DuCUG). RES Software named Ingmar RES Software Valued Professional in 2014.

More Posts - Website

Follow Me:
TwitterLinkedInGoogle Plus

Tags: , , , ,

Comments (6)

  • olivierdsm
    5 April 2012 at 14:22 |

    Thanks for the Fix.
    The Script worked perfectly for me!

  • Foley
    22 May 2013 at 14:44 |

    Thanks for the article. Fixed my issue Citrix XenApp servers. I found a CTX related article that mentions to go to add/remove programs and modify the vmware tools installation by unchecking vmware shared folders. VMware tools cannot be modified/change on my servers. Your fix helped as a work around.

    • Ingmar Verheij
      22 May 2013 at 16:28 |

      Good to hear the article helped!

  • Jeff
    8 July 2013 at 20:39 |

    I made the change Provider Order now = SnacNp,PICAClientNetwork,RDPNP,LanmanWorkstation,webclient,PnSson

    However, I’m still getting Profile Bloating. Any other suggestions?

    • Ingmar Verheij
      9 July 2013 at 09:05 |

      Are your profiles bloating or aren’t they removed after users logoff? These are two complete different problems (with different solutions).

  • Koos
    19 September 2013 at 16:42 |

    Great, very clear article 🙂

Leave a comment



%d bloggers like this: