@echo off @setlocal set BATNAME=pathtest_is_this_file_on_the_path.bat set THISDIR=%~dp0 set TESTDIR=%THISDIR%foo;bar\ set TESTBAT=%TESTDIR%%BATNAME% if not exist "%TESTDIR%" mkdir "%TESTDIR%" echo @exit /b 0 >"%TESTBAT%" set PATH= call :dotest set PATH=%THISDIR%foo;bar call :dotest set PATH=%THISDIR%"foo;bar" call :dotest set PATH="%THISDIR%foo;bar" call :dotest set PATH=%THISDIR%"foo;"bar call :dotest set PATH=%THISDIR%foo";"bar call :dotest set PATH=%THISDIR%""foo";"bar"" call :dotest set PATH= call :dotest set PATH=%THISDIR%foo";bar call :dotest del "%TESTBAT%" rmdir "%TESTDIR%" goto :eof :dotest echo PATH=%PATH% call %BATNAME% 2> NUL && echo SUCCESS || echo FAIL echo. exit /b 0