Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Checking multiple number values in a windows BAT file  (Read 2807 times)

0 Members and 1 Guest are viewing this topic.

manas0603

    Topic Starter


    Newbie

    Checking multiple number values in a windows BAT file
    « 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

    oldun

    • Guest
    Re: Checking multiple number values in a windows BAT file
    « Reply #1 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

    mroilfield



      Mentor
    • Thanked: 42
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 11
    Re: Checking multiple number values in a windows BAT file
    « Reply #2 on: February 10, 2009, 05:34:25 AM »
    What is the purpose of this batch file?
    You can't fix Stupid!!!