@echo off :: This batch file checks if a drive letter is mapped or not. :: It exits with 0 if the drive is mapped and 1 if it isn't. SET gdrive=G if exist %gdrive%:\ ( echo The %gdrive% drive is mapped Exiting with 0 to continue running. exit /b 0 ) echo The %gdrive% drive is NOT mapped. Exiting with 1 to restart. exit /b 1