检查批处理文件中的参数数量

roc*_*now 1 batch-file

我正在尝试对批处理文件进行简单检查。argCount包含正确的数字,但是比较变量和数字时遇到麻烦。如果参数数量不等于3,我想显示帮助,然后转到文件末尾。
我试过:
if not %argCount% == 3
if not %argCount%=='3'
if not '%argCount%'=='3'
if %argCount% NEQ 3
但是这些选项都没有按预期的方式工作...尝试的大多数选项始终会向我显示帮助消息,而不管参数的数量如何,如果我将3个参数传递给我,则某些选项会向我显示帮助消息而没有前三行脚本(非常奇怪)。

@echo off

set argCount=0
for %%x in (%*) do (
   set /A argCount+=1
)
if not %argCount% == 3 (
    echo This script requires the next parameters:
    echo - absolute path to file
    echo - filter (explanation)
    echo - true or false (explanation)
    echo Examples:
    echo start.bat full\path\to\the\file.ext test true
    echo start.bat full\path\to\the\file.ext nof false
    goto end
)

REM some another code

:end
Run Code Online (Sandbox Code Playgroud)

Com*_*mpo 5

为什么不只是简化结构:

IF NOT "%~3"=="" IF "%~4"=="" GOTO START
ECHO This script requires the next parameters:
ECHO - absolute path to file
ECHO - filter (explanation)
ECHO - true or false (explanation)
ECHO Examples:
ECHO "%~nx0" "full\path\to\the\file.ext" test true
ECHO "%~nx0" "full\path\to\the\file.ext" nof false
GOTO :EOF

:START
Run Code Online (Sandbox Code Playgroud)