Tip for virtualizing Citrix servers involving user profiles

October 25th, 2008 by jason Leave a reply »

I virtualize Citrix servers and have had great success since VI3 was released. One of the things I learned along the way was a conflict that was created when introducing VMware Tools to a Citrix server.

My Citrix users receive mandatory profiles when their first session is established with the Citrix server. Although the user is assigned a mandatory read only profile which lives in an isolated directory on each Citrix server, a profile bearing the user’s account name is still created under \Documents and Settings\<username>\. This is normal Windows Terminal Services behavior. Now, what’s supposed to happen is when the user logs off their Citrix session, the automatically created profile is supposed to be automatically deleted. However, the installation of VMware Tools will prevent the clean up and deletion of the profile. The next time that user logs on, a new profile folder is created with a .001 extension. Then .002.  Then .003.  And so on.  On a larger scale with many users logging on and logging off, many profile folders are created and then orphaned. Left undiscovered, several hundred orphan folders will be discovered within just a day or two depending on how many sessions the Citrix server handles.

The root cause is that a file named \Documents and Settings\<username>\Application Data\VMware\hgfs.dat cannot be deleted by Windows and thus the folder structure must remain in place. The VMware Tools installation is partly responsible for the conflict. When VMware Tools is installed, it appends a value in the Windows registry to

HKEY_LOCAL_MACHINE\

SYSTEM\

CurrentControlSet\

Control\

NetworkProvider\

Order\

ProviderOrder

The value of hgfs is appended.

The fix is simple. Right-click ProviderOrder and choose Modify. In the Edit String Value dialog box, edit the value data string and remove the characters ,hgfs (including the leading comma). For example, if the data string contains LanmanWorkstation,hgfs then change it to LanmanWorkstation. If the value data string contains only hgfs, then erase it and leave the value data string empty.

Problem solved. Unfortunately only for the time being. The next time you upgrade VMware Tools on the Citrix VM, hgfs will be appended back in the registry and once again an accumulation of folders under \Documents and Settings\ will begin.

Advertisement

No comments

  1. Andrew Storrs says:

    The User Profile Hive Cleanup Service (UPHClean) from Microsoft will take care of this problem and should be a “must install” tool on any Citrix/Terminal Server.

    Download it here: http://snipr.com/4ortz

  2. jason says:

    I’ve had UPHClean installed since day one (I install this service as a best practice on most of my Windows servers). UPHClean is unable to resolve the hgfs issue. If you know of a UPHClean tweak to handle hgfs, please share 🙂

  3. Andrew Storrs says:

    Sorry you’re right it’s UPHClean 2.0 (in beta) that fixes it http://snipr.com/4p2qh

    32-bit download:
    http://blogs.technet.com/uphclean/attachment/2940877.ashx

    64-bit download:
    http://blogs.technet.com/uphclean/attachment/2940834.ashx

    Be aware some people have had problems with the beta (I haven’t seen any on a few hundred Citrix servers) so you’d want to thoroughly test it in your environment. Hopefully they release a final version sometime in the next 6 months.

  4. jason says:

    No need to apologize.

    Yeah, d has been out forever. That’s the last known stable version I’m aware of so it’s the version I have been using in production for quite a while. Thank you for your comments.

  5. Chad says:

    Thank you for this article (despite its age). We are suffering from exactly this problem. I found the registry key entry exactly as stated except it was called vmhgfs with Vsphere 4 tools.

  6. jason says:

    Thank you for the comment. I will look at updating the article for vSphere.

  7. Thuan Nguyen says:

    Thank you for this article. We are suffer the same thing on Vsphere 4 and it drving us crazy.

  8. Matt Taylor says:

    Modifying the VMware tools install and unchecking shared folders should do the same thing. Then, just leave the shared folders option unchecked during future tools upgrades.

  9. Josh Dunigan says:

    Here’s a script that can be added through policy that should resolve most of these issues. Name it something.vbs and voila.

    ON ERROR RESUME Next

    Const HKEY_LOCAL_MACHINE = &H80000002

    Set WSHShell = CreateObject(“WScript.Shell”)

    strKeyPath = “SYSTEM\CurrentControlSet\Control\NetworkProvider\Order”
    strValueName = “ProviderOrder”
    strComputer = “.”

    Set oReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & strComputer & “\root\default:StdRegProv”)

    oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue

    strNewValue = Replace(strValue, “,vmhgfs”, “”)
    strNewValue = Replace(strNewValue, “,vmhgs”, “”)
    strNewValue = Replace(strNewValue, “,hgfs”, “”)
    strNewValue = Replace(strNewValue, “vmhgfs,”, “”)
    strNewValue = Replace(strNewValue, “vmhgs,”, “”)
    strNewValue = Replace(strNewValue, “hgfs,”, “”)
    strNewValue = Replace(strNewValue, “,,”, “,”)

    oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strNewValue

    Wscript.quit

  10. CDave says:

    I know this is a very old posting, but VMHGFS continues to be a problem when using the Automated installation or upgrade of VMware Tools.

    I wrote a simple script that you can run from whatever your favorite tool to run apps/scripts/whatever.

    ‘————————————————————————————
    ‘ Purpose: Check for and remove VMWare Tools Shared Folders Provider
    ‘ 02/09/2014 – dclark
    ‘ Usage: cscript DEL-vmhgfs.vbs
    ‘————————————————————————————
    Dim strRegValue, strRegArray, strNewArray, strNewRegValue
    Set WshShell = CreateObject( “WScript.Shell” ) ‘Bind to the Registry provider

    strRegValue = WshShell.RegRead( “HKLM\System\CurrentControlSet\Control\NetworkProvider\Order\ProviderOrder” )
    strRegArray = Split(strRegValue,”,”) ‘Copy Registry values into an Array
    strNewArray = RemoveArrayElement(strRegArray, “vmhgfs”)
    strNewRegValue = Join(strNewArray, “,”)
    WshShell.RegWrite “HKLM\System\CurrentControlSet\Control\NetworkProvider\Order\ProviderOrder”, strNewRegValue, “REG_SZ”

    ‘———————
    ‘ Strip unwanted array element
    ‘———————
    Function RemoveArrayElement(ByVal MyArray, ByVal Item)
    Dim S, N
    S = “”
    For N = 0 To UBound(MyArray)
    If StrComp(MyArray(N), Item, vbTextCompare) 0 Then
    If S “” Then
    S = S & vbTab & MyArray(N)
    Else
    S = MyArray(N)
    End If
    End If
    Next
    RemoveArrayElement = Split(S, vbTab)
    End Function

  11. CDave says:

    Oops, don’t know how I missed that someone else has provided a script also. Oh well, now you have choices 🙂