I'm trying to put a batch file together to run a program on each logical drive on a system except for optical drives. It filters out the optical drives just fine but for some reason my echo of the built up command I am testing with runs one extra time except the variables have no values. It's like the loop is iterating an extra time on a null value. Ideas?
(The IF NOT !drive! == %safe% is just making sure I don't run the command for the drive the script lives on and "safe" is just an acronym)
for /F "usebackq skip=1 tokens=1,2" %%a IN (`wmic logicaldisk get DeviceID^,DriveType`) do (
SET drive=%%a
SET driveType=%%b
IF NOT !drive! == %safe% (
IF NOT !driveType! == 5 (
ECHO test commands
)
)
)