title: How to check command line parameter in ".bat" file?
body: <p>My OS is Windows Vista.  I need to have a ".bat" file where I need to check if user enters any command-line parameter or not.   If does then if the parameter equals to <code>-b</code> then I will do something otherwise I will flag "Invalid input". If user does not enter any command-line parameter then I will do something. I have created following .bat file. It works for <code>-b</code> and not-equal to <code>-b</code> cases - but it fails when user does not pass any command-line parameter.</p>
  
  <p>I always get error:</p>
  
  <pre><code>GOTO was unexpected at this time.
  </code></pre>
  
  <p>Can anyone tell me what am I doing wrong here?</p>
  
  <hr>
  
  <pre><code>ECHO OFF
  CLS
  ECHO.
  
  IF [%1]==[/?] GOTO BLANK
  
  IF %1=="-b" GOTO SPECIFIC
  
  IF NOT %1=="-b" GOTO UNKNOWN
  
  :SPECIFIC
  
  ECHO SPECIFIC
  
  GOTO DONE
  
  :BLANK
  
  ECHO No Parameter
  
  GOTO DONE
  
  :UNKNOWN
  
  ECHO Unknown Option
  
  GOTO DONE
  
  :DONE
  
  ECHO Done!
  </code></pre>