Monday, May 28, 2012

Tfs_DAV folder filling up C: drive

After having spent some time using WEBDAV on one of my Windows 7 computers, I have discovered that my system drive (C:) was filling up quite quickly. After deep investigation I have discovered that any file downloaded or uploaded from/to a network drive mapped with WEBDAV gets copied to a cache on the local system. The location for this local cache is always "c:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp\TfsStore\Tfs_DAV" in Windows 7.

Unfortunately I wasn't able to find the meaning of that 'tfs' acronym in this context, nor I have succeeded in disabling this behavior. What I have understood so far is that:
  • Files from this folder never get deleted (unless you do it manually) 
  • You can't disable it
  • You can't change its location (unless you create a symbolic link)
  • There is no registry key specifying its behavior
  • You can delete this Tfs_DAV folder
  • If you delete Tfs_DAV you will be able to browse WEBDAV drives
  • If you delete Tfs_DAV you will be able to right-click on a field and get its properties
  • If you delete Tfs_DAV you won't be able to open any file, not even text documents
Technically speaking, when you delete that Tfs_DAV folder, the svchost.exe process (started with this commandline: C:\Windows\system32\svchost.exe -k WebClientGroup) will try to get to "C:\Windows\SERVIC~2\LOCALS~1\AppData\Local\Temp\TfsStore\Tfs_DAV" with an IRP_MJ_CREATE operation and gets PATH NOT FOUND as result.

A solution to this problem of the system drive getting filled up with cached copies of network files is to move the Tfs_DAV folder to a different drive.

Here's my batch script to do it:
e:
mkdir Tfs_DAV
c:
cd "c:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp\TfsStore\"
del Tfs_DAV /f /q
mklink Tfs_DAV e:\Tfs_DAV
If the delete command fails, just delete Tfs_DAV from Windows Explorer then rerun this script.

If the procedure succeeds, you will get an output like this:
symbolic link created for Tfs_DAV <<===>> e:\Tfs_DAV 
This is the best I could do for the moment. I will keep investigating the internals of WEBDAV (such as the functioning of the redirectors mrxdav.sys, rdbss.sys and MUP) and will keep this post up-to-date as soon as I find a better workaround than moving Tfs_DAV to another drive.

If you feel like contributing to this post do not hesitate to share your knowledge or experience!

6 comments:

  1. I have scheduled a calendar pop-up for each Saturday to clear the Tfs_DAV. I merely delete all the files in the folder and I haven't encountered any problems. The first time that I performed this task I have over 5.5GB of files that I was able to delete.

    ReplyDelete
  2. Thanks for the hint!
    I have found another solution; net start and net stop the Webclient service and the Tfs_DAV cache folder gets immediately cleared by the system.
    I don't think I'll ever find a way to deactivate this cache because, as far as I have understood, caching is the essential background process that make WebDav browsing possible. Unfortunately this adds a lot of overhead because many files are downloaded just if you move your mouse over them of if you check their properties. It looks like the system tries to guess which file you are going to download next, and copies it to the cache before you really double-click on it...
    Any other experience to share with this mechanism?

    ReplyDelete
    Replies
    1. @Carlo: Are you running Win7? Cause net start/stop didn't clean my cache folders. Strange.

      Delete
    2. Hi Günther,

      yes, I am using windows 7 and the stop/start method works flawlessly.

      To be sure, I just checked it is still working by issuing a "restart-service webclient" in Powershell:

      PS C:...\TfsStore\Tfs_DAV> dir

      Name
      ----
      ASTREINTES1.txt
      Automation%20Architecture0.jpg
      bootprocess0.docx
      citrix0.docx
      Perfmon2007_20030.xls
      template0.doc


      PS C:...\TfsStore\Tfs_DAV> Restart-Service webclient
      PS C:...\TfsStore\Tfs_DAV> dir
      PS C:...\TfsStore\Tfs_DAV>

      As you can see the second 'dir' command returns nothing. I can suggest you to fire powershell and simply input "restart-service webclient" and this should do.

      Regards

      Carlo

      Delete
  3. I only got this message when I did it with parameter /J:

    c:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp\TfsStore>mklink /J Tfs_DAV "D:\Programme(x86)\Microsoft_Tfs_DAV"
    Verbindung erstellt für Tfs_DAV <<===>> D:\Programme(x86)\Microsoft_Tfs_DAV

    ReplyDelete
  4. Create vbs file with the following information, then run as a task - under task scheduler...

    ==========================
    DIM ObjFSO, strTargetName, strFolder, arrExtension, strExtension, strFile, StrFileName, strSubFolder, fFolder

    Set ObjFSO = CreateObject("Scripting.FileSystemObject")
    strTargetName = "C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp\TfsStore\Tfs_DAV\"

    arrExtension = Array("docm","docx","ppam","ppsm","ppsx","pptm","pptx","sldm","sldx","xlam","xlsb","xlsm","xlsx")

    Set strFolder = ObjFSO.GetFolder(strTargetName)

    '*********************************
    ' delete all files in root folder
    '*********************************
    '
    For Each strExtension In arrExtension
    For each strFile in strFolder.Files
    On Error Resume Next
    StrFileName = ""
    StrFileName = strFile.name
    If LCase(objFSO.GetExtensionName(strFileName)) = strExtension Then
    StrFile.Delete True
    End If
    On Error GoTo 0
    Next

    Call ShowSubfolders (strFolder)
    Next
    Wscript.quit (0)


    '*********************************
    ' delete all subfolders and files
    '*********************************
    '
    Sub ShowSubFolders(fFolder)
    Set objFolder = objFSO.GetFolder(fFolder.Path)
    For each strFile in objFolder.Files
    On Error Resume Next
    StrFileName = ""
    StrFileName = strFile.name
    If LCase(objFSO.GetExtensionName(strFileName)) = strExtension Then
    StrFile.Delete True
    End If
    On Error GoTo 0
    Next

    For Each Subfolder in fFolder.SubFolders
    ShowSubFolders(Subfolder)
    Next
    End Sub
    ===================================

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...