GetPartitionSizeInMiB

@echo off

set DISK=4

set PNO=0

echo Get physical disk %DISK% partition %PNO% size in MiB (Base 1024)

set PSB=

set PSMB=

for /f "tokens=5" %%B in ('wmic partition where DiskIndex^=%DISK%  get size^,name  ^| find "#%PNO%"') do set PSB=%%B

echo PSB=%PSB% Bytes

echo wsh.echo int(cdbl(%PSB%)/(1024*1024)) > %temp%.\tmp.vbs

for /f %%a in ('cscript //nologo %temp%.\tmp.vbs') do set PSMB=%%a

del %temp%.\tmp.vbs

echo PSMB=%PSMB% MiB



F:\temp>getpsize.cmd

Get physical disk 4 partition 0 size in MiB (Base 1024)

PSB=299977670656 Bytes

PSMB=286081 MiB