Free tool/script for directory size calculation [closed]

Du by Sysinternals might be what you're looking for. It's free from Microsoft, and it's basically a rudimentary version of the *ix du. It deals with junctions and denied permissions by reporting the file doesn't exist.

http://technet.microsoft.com/en-us/sysinternals/bb896651

Du v1.34 - report directory disk usage
Copyright (C) 2005-2009 Mark Russinovich
Sysinternals - www.sysinternals.com

usage: du [[-v] [-l <levels>] | [-n]] [-q] <directory>
   -l     Specify subdirectory depth of information (default is all levels)
   -n     Do not recurse.
   -q     Quiet (no banner).
   -u     Count only unique file occurences.
   -v     Show size (in KB) of intermediate directories.

c:\sysinternals>du c:\sysinternals

Du v1.34 - report directory disk usage
Copyright (C) 2005-2009 Mark Russinovich
Sysinternals - www.sysinternals.com

Files:        101
Directories:  0
Size:         32,798,999 bytes
Size on disk: 32,798,999 bytes

Using robocopy with /l will do it, ignoring things that you don't have access to, and /B will even try in backuo mode, which might get you access you otherwise wouldn't have.

/L :: List only - don't copy, timestamp or delete any files.

/XJ :: eXclude Junction points. (normally included by default).

Is there anything specific you meant by "gracefully deal with access denied to some subfolder" ?

/Edit - now that you've asked essentially an entirely new question, I will flood you with other answers:

Do why do you need it running on Windows 7? Run it on the server (s).

How do you expect to see this used? Crystal Reports can use a filesystem as a reporting source, and you could group by size in one report, and by number of files in another. Does it need to have history? You could use something like RRDTool to run diruse on every folder in the parent directory or directories where you keep your homedirs. And then you have nice pretty webpages with nice pretty graphs.

For interactive use, I love WinDirStat, but some people like TreeSize Pro.

How does this tie into your need to have this be redistributable? Are you trying to build and sell a management product for other IT admins? If it's just for you and your staff, that's not "redistributing."