Code: Select all
@echo off & setlocal
for %%x in ("%__CD__%") do set "ThisVolume=%%~dx"
(
echo sel vol %ThisVolume%
echo attr disk
) | diskpart | ( findstr /i "Read-only : No" >nul && echo Disk is not protected!)
That works because selecting a volume will implicitly select the right disk too.