check if a removable drive exists before running
Posted: 30 May 2016 23:51
Hi,
I am using this, to eject a removable drive.
But if a removable drive does not exists, there's no point in running this. So I need to check if a removable drive exists, and if it doesn't, echo a message saying that a removable drive does not exist.
how can I do this?
I am using this, to eject a removable drive.
Code: Select all
echo Removing Drive
for /F "tokens=1*" %%a in ('fsutil fsinfo drives') do (
for %%c in (%%b) do (
for /F "tokens=3" %%d in ('fsutil fsinfo drivetype %%c') do (
if %%d equ Removable (
%~dp0RemoveDrive.exe %%c -L -b
)
)
)
)
But if a removable drive does not exists, there's no point in running this. So I need to check if a removable drive exists, and if it doesn't, echo a message saying that a removable drive does not exist.
how can I do this?