Try this:
@echo off
Setlocal EnableDelayedExpansion
for /f %%d in ('wmic logicaldisk where "drivetype=2 and access=0" get name^|find ":"') DO (
SET "curDrive=%%d"
if exist "!curDrive!\file.txt" (
Echo found it.
) ELSE (
Echo File not found.
)
)
You're returning extra carriage returns that need to be filtered out.