I defined a function, the strange thing is that the function lines are executed even if I do NOT call the function !!
echo off
cls
REM call:ctrlService "stop" "1.1.1.1"
echo.SERVICES STARTED
:ctrlService - Generic function
echo.Parameter 1: %~1
echo.Parameter 2: %~2
dir
GOTO:EOF
echo on
I see the echo statements executed, without values displayed for the relative parameters. And the dir command is executed too !
How can I stop the function from being executed on it's own ?
:ctrlServicewon't prevent interpreter to skip the following lines (the ones you would call function body). Usually you define your functions at the end of batch file and make the interpreter togoto :eofbefore it reaches the definitions. – Vlastimil Ovčáčík Sep 29 '13 at 15:13