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

What's Wrong with Group Policy

What's Wrong with Group Policy
Over the years I have worked with Group Policy in many different ways. My experience ranges from helping an enterprise client establish a brand new set of policies for physical PCs and VDI machines to authoring ADM/ADMX/ADML files. Last year I presented and wrote a very detailed analysis of the impact of Group Policy on user logon performance (blog posts). Along the way I learned a lot about the strengths but also about the weaknesses of Group Policy. This article is an account of the latter.
Windows General

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

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