Determining the Size of a Folder without Access or Permissions

Imagine you need to determine the size of a directory, but you do not have access to it and cannot change the permissions, either. Such a situation is common with Windows user profiles. This article shows how to deal with it.

Determine Folder Size

There are several ways to determine the size of a directory from the command line. But the possibly obvious choice, the command diruse.exe, cannot be used with user profiles - like many other tools it does not know how to handle the directory junctions in V2 profiles.

Of course, there is always the possibility of rolling your own, for example as a PowerShell script. But it is much easier (and also less error-prone) to resort to a proven tool like the Sysinternals interpretation of the popular Unix tool du. Usage is simple:

C:\temp>du -q c:\Users\test
Files:        281
Directories:  174
Size:         25.127.247 bytes
Size on disk: 25.127.247 bytes

There is only one problem with du: it cannot bypass security and count every file regardless of permissions. Basically you only see what you are allowed to see. Here is an interesting way around that limitation, using robocopy’s ability to list every file in backup mode:

C:\temp>robocopy c:\users\test c:\dummy /l /xj /e /nfl /ndl /njh /r:0 /b


------------------------------------------------------------------------------

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :       175       158        17         0         0         0
   Files :       281       281         0         0         0         0
   Bytes :   23.96 m   23.96 m         0         0         0         0
   Times :   0:00:00   0:00:00                       0:00:00   0:00:00

   Ended : Thu Apr 28 22:40:35 2011

Do you know of other ways to calculate a directory’s size without having access to it? Let us know!

Comments

Related Posts

Folder Redirection - Denial of Service Waiting to Happen

Folder Redirection - Denial of Service Waiting to Happen
This article is part of Helge’s Profile Toolkit, a set of posts explaining the knowledge and tools required to tame Windows user profiles. One of the problems inherent to roaming user profiles is that they are copied to the local computer during logon. That takes time. Hence the motivation to limit the size of user profiles. One way of doing that is to put a quota on them, another one is folder redirection. Although widely used, redirection has its problems; problems so grave that Shawn Bass started to campaign against using folder redirection altogether. In this article I describe why Shawn despises redirection, which alternatives are available now what we can hope for in the future.
User Profiles

Latest Posts