Computer Hope

Software => Computer software => Topic started by: manas0603 on February 09, 2009, 11:45:45 PM

Title: Checking multiple number values in a windows BAT file
Post by: manas0603 on February 09, 2009, 11:45:45 PM
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 <PARAMTER VALUE> NOT IN (0,1) THEN
  GOTO :PARAMETER_ERR

Please let me know how to do this. I am using windows XP and windows 2003 server
Title: Re: Checking multiple number values in a windows BAT file
Post by: oldun on February 10, 2009, 04:07:52 AM
Maybe 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
Title: Re: Checking multiple number values in a windows BAT file
Post by: mroilfield on February 10, 2009, 05:34:25 AM
What is the purpose of this batch file?