0
4

2 回答 2

1

为每个函数使用一个批处理标签。只需转到第一批参数指定的标签。每个“函数”都可以访问以 开头的附加参数%2

@echo off
goto %1

:PARAMETER1
REM execute code here
exit /b

:PARAMETER2
REM execute code here
exit /b
于 2013-02-16T16:51:58.760 回答
0

我会让我的脚本有点不同:

@echo off
goto %1
goto :end

:: functions

:PARAMETER1 comment1
REM execute code here
exit /b 0

:PARAMETER2 comment2
REM execute code here
if %ERRORLEVEL%==1 ECHO goto :error
exit /b 0

:error
ECHO Error occurred with arg %1
timeout 10
exit 1

:: end of script
:end
ECHO Finished
于 2013-02-16T18:00:08.887 回答