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

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

Fast & Silent 5 Watt PC: Minimizing Idle Power Usage

Fast & Silent 5 Watt PC: Minimizing Idle Power Usage
This micro-series explains how to turn the Lenovo ThinkCentre M90t Gen 6 into a smart workstation that consumes only 5 Watts when idle but reaches top Cinebench scores while staying almost imperceptibly silent. In the first post, I showed how to silence the machine by replacing and adding to Lenovo’s CPU cooler. In this second post, I’m listing the exact configuration that achieves the lofty goal of combining minimal idle power consumption with top Cinebench scores.
Hardware

Fast & Silent 5 Watt PC: Lenovo ThinkCentre M90t Modding

Fast & Silent 5 Watt PC: Lenovo ThinkCentre M90t Modding
This micro-series explains how to turn the Lenovo ThinkCentre M90t Gen 6 into a smart workstation that consumes only 5 Watts when idle but reaches top Cinebench scores while staying almost imperceptibly silent. In this first post, I’m showing how to silence the machine by replacing and adding to Lenovo’s CPU cooler. In a second post, I’m listing the exact configuration that achieves the lofty goal of combining minimal idle power consumption with top Cinebench scores.
Hardware