DiskUsage


Determine total size in MB used by various folders under Windows\WinPE 32-bit OS or 64-bit OS

Requires SysInternals DU.exe and DU64.exe

ref:

 https://ss64.com/nt/syntax-64bit.html

https://docs.microsoft.com/en-us/sysinternals/downloads/du




@echo offset TSIZE=0REM Use DU64.exe if 64-bit OS, else use DU.exe:: Get Installed OSset _os_bitness=64IF %PROCESSOR_ARCHITECTURE% == x86 (  IF NOT DEFINED PROCESSOR_ARCHITEW6432 set _os_bitness=  )set MYDU=DU%_os_bitness%.execall :calcsize "C:\temp"call :calcsize "C:\usb"echo TOTAL=%TSIZE%MBgoto :EOF

:calcsizeset DIR=%1for /f "tokens=2" %%f in ('%MYDU% -q -nobanner %DIR% 2^> nul ^| find /i "Size:"') do set size=%%fset size=%size:,=%set size=%size:~0,-6%set /a DIRSIZE=%size%+1REM echo Size of %DIR%=%DIRSIZE%MBset /a TSIZE=%TSIZE%+%DIRSIZE%set size=goto :eof

To suppress the SysInternals pop-up on first run.

ref: https://hahndorf.eu/blog/post/2010/03/07/WorkAroundSysinternalsLicensePopups


reg.exe ADD HKCU\Software\Sysinternals /v EulaAccepted /t REG_DWORD /d 1 /f
reg.exe ADD HKU\.DEFAULT\Software\Sysinternals /v EulaAccepted /t REG_DWORD /d 1 /f