
@echo off
ECHO.%0 | FINDSTR /C:\ /C:/ >NUL && (
        @echo st dir to dp0
        SET dir=%~dp0
) || (
        FOR /F %%i IN ('where %0') DO @SET dir=%%~dpi
)

echo 0 = %0
echo dp0 = %~dp0
echo dir = %dir%

call :find_bin
echo dir after call = %dir%
exit /b

:find_bin
set dir=%~dp0
exit /b
