1.

Solve : Checking multiple number values in a windows BAT file?

Answer»

Hi All,

I am running a windows batch file which will ACCEPT a single value as a parameter.
The value is either 0 or 1.

Inside the batch file i want to check if the parameter is not 0 or 1 then it will generate an error.

It is something like this.

IF NOT IN (0,1) THEN
GOTO :PARAMETER_ERR

Please let me know how to do this. I am using windows XP and windows 2003 serverMaybe something like this?

Code: [SELECT]@Echo Off
If [%1] EQU [] (Echo Param REQUIRED & Goto End)
If %1 LSS 0 (Goto ParamError) Else If %1 GTR 1 (Goto ParamError)
Echo Param passed was %1
Goto End
:ParamError
Echo Wrong parameter passed. Must be 0 or 1
:End
What is the purpose of this batch file?



Discussion

No Comment Found