Using DiskUse.exe, I have scripted UserSpace.bat to report the total disk space that each user consumes on a set of file system objects that you specify.

The syntax for using UserSpace.bat is:

UserSpace ReportFile Object1 \[object2 ... objectN\]


<b>ReportFile</b> is the file that will receive the output, in the <b>CSV</b> format of <b>"User","<Space Used>"</b>.
<b>Object</b><i>X</i>    is a file system object, like <b>C:</b> or <b>\\ComputerName\C$</b> or <b>\\ComputerName\ShareName</b>.
NOTE: Other scripts that use DiskUse.exe are:
        <a href="/article/jsifaq/jsi-tip-9571-how-can-i-generate-a-report-of-sorted-file-sizes-.aspx">How can I generate a report of sorted file sizes?</a>

        <a href="/article/jsifaq/jsi-tip-9645-how-can-i-return-the-disk-space-used-by-an-owner-in-a-folder-.aspx">How can I return the disk space used by an owner in a folder?</a>
UserSpace.bat contains:
@echo off
if \{%2\}<h1><a name="_echo_syntax_UserSpace_ReportFile_Object1_object2_objectN_amp_goto_EOF_setlocal_EnableDelayedExpansion_set_report_1_if_exist_report_del_q_report_set_rpt1_TEMP_UserSpace1__RANDOM_tmp_set_rpt2_TEMP_UserSpace2__RANDOM_tmp_set_rpt3_TEMP_UserSpace3__RANDOM_tmp_echo_User_NONE_gt_rpt1_echo_SpaceUsed_0_gt_gt_rpt1_shift_loop_if_1_">\{\} @echo syntax: UserSpace ReportFile Object1 \[object2 ... objectN\]&goto :EOF
setlocal EnableDelayedExpansion
set report=%1
if exist %report% del /q %report%
set rpt1="%TEMP%\UserSpace1_%RANDOM%.tmp"
set rpt2="%TEMP%\UserSpace2_%RANDOM%.tmp"
set rpt3="%TEMP%\UserSpace3_%RANDOM%.tmp"
@echo User: NONE>%rpt1%
@echo SpaceUsed: 0>>%rpt1%
if \{%1\}</a></h1>\{\} goto reportit
set object=%1
if not exist %object% @echo Syntax: UserSpace %object% NOT found.&goto loop1
call :quiet>nul 2>&1
copy %rpt1%+%rpt2% %rpt3% >nul
del /q %rpt2%
copy %rpt3% %rpt1% /Y >nul
del /q %rpt3%
goto loop
diskuse %object% /s /f:%rpt2%
goto :EOF
for /f "Tokens=1*" %%a in ('type %rpt1%^|findstr "User: SpaceUsed:"') do (
 if "%%a" EQU "User:" set usr="%%b"
 if "%%a" EQU "SpaceUsed:" @echo !usr!,"%%b">>%rpt2%
del /q %rpt1%
sort %rpt2% /O %rpt1%
del /q %rpt2%
set prev="NONE"
set total=0
for /f "Tokens=1* Delims=," %%a in ('type %rpt1%') do (
 if /i %%a NEQ !prev! call :out %%a
 call :add %%b
del /q %rpt1%
goto :EOF
if %prev% EQU "NONE" goto outend
@echo !prev!,"!total!">>%report%
set total=0
set prev=%1
goto :EOF
set numb=%1
set numb=%numb:"=%
for /f %%i in ('domath //nologo "!Total! + %numb%"') do (
 set total=%%i