Loading ...
Sorry, an error occurred while loading the content.

suggest me!!

Expand Messages
  • batch exe
    Hi guys, I want to know how many parameters has been passed to a batch file based on that i want validated some conditions i.e if i pass parameters to batch
    Message 1 of 2 , May 4 7:20 AM
    • 0 Attachment
      Hi guys,

      I want to know how many parameters has been passed to a batch file based on that i want validated some conditions i.e if i pass parameters to batch file called "Run" like shown below in dos prompt

      Run abc bcd cde def

      , i want to get how many parameters is passed to it
      if its 4, i will do some validations and if 3 then do som other like that .Hope u guys understand !!



      Thanx,


      ---------------------------------
      Do you Yahoo!?
      Win a $20,000 Career Makeover at Yahoo! HotJobs

      [Non-text portions of this message have been removed]
    • Michael Marquart
      On stardate Tue, 4 May 2004 07:20:06 -0700 (PDT), Captain batch exe spake ... Here s one way. @echo off if [%1]==[] echo parameters = none & goto :EOF if
      Message 2 of 2 , May 4 7:41 AM
      • 0 Attachment
        On stardate Tue, 4 May 2004 07:20:06 -0700 (PDT), Captain batch exe spake
        thusly:

        > Hi guys,
        >
        > I want to know how many parameters has been passed to a batch file based on that i want validated some conditions i.e if i pass parameters to batch file called "Run" like shown below in dos prompt
        >
        > Run abc bcd cde def
        >
        > , i want to get how many parameters is passed to it
        > if its 4, i will do some validations and if 3 then do som other like that .Hope u guys understand !!
        >

        Here's one way.

        @echo off
        if [%1]==[] echo parameters = none & goto :EOF
        if [%2]==[] echo parameters = 1 & goto :EOF
        if [%3]==[] echo parameters = 2 & goto :EOF
        if [%4]==[] echo parameters = 3 & goto :EOF
        if [%5]==[] echo parameters = 4 & goto :EOF
        if [%6]==[] echo parameters = 5 & goto :EOF
        if [%7]==[] echo parameters = 6 & goto :EOF
        if [%8]==[] echo parameters = 7 & goto :EOF
        if [%9]==[] echo parameters = 8 & goto :EOF
        echo there are 9 or more parameters



        --
        Regards,
        Michael
      Your message has been successfully submitted and would be delivered to recipients shortly.