在子程序中,%0会展开为子程序名称,而不是脚本名称。是否有合法的方法仍然可以访问脚本名称,还是应该将其作为参数传递?
@echo off
call :subroutine %~f0 my parameters
exit /b
:subroutine
shift
echo Script name is %0
echo Parameters: %1 %2
exit /b
我希望“调用语句”只需这样
call :subroutine my parameters