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

Why User Profiles Always Get Bigger, Never Smaller: Installers

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 constants in the Windows universe is the knowledge that user profiles increase in size over time. They tend to accumulate all kinds of junk and become bloated which is especially cumbersome in the case of roaming profiles because all that “weight” is copied across the network time and again, slowing down the logon process.
User Profiles

Lenovo Yoga 900: SSD Upgrade & Clean Windows Installation

Lenovo Yoga 900: SSD Upgrade & Clean Windows Installation
The Lenovo Yoga 900 packs some amazing hardware in an ultraportable 1.29 kg 13" chassis: high-resolution 3200x1800 screen, Intel Core i7-6500U CPU, 16 GB RAM. The only downsides I found so far: glossy display, maximum SSD size is 512 GB, OS is Windows Home, not Pro. There is not much we can do about the former, but we can change latter two pretty easily. This article explains how to upgrade the SSD and install a clean Windows 10 Pro without any Lenovo bloatware.
Hardware

Latest Posts