0

I know how to check if there are removable disks connected with a CMD command

wmic logicaldisk where drivetype=2 get deviceid, volumename, description

But now I would like to make a batch that checks if there's any removable disks connected, and if so, then it would execute another command or run another batch.

How would I do this?

1 Answer 1

0

Use the following:

wmic logicaldisk where drivetype=2 get deviceid, volumename, description | findstr /C:"Removable Disk"
if %errorlevel% == 0 (
    Rem Put commands in here to run if disk is found
) else (
    Rem Put commands in here to run if disk not found
)

The easiest way is to set your batch file to run on a scheduled task every x minutes - although it could take a up to that many minutes before the removable disk is "detected".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .