title: Show help message if any command line argument equals /?
body: <p>I wish to write a Windows Batch script that first tests to see if any of the command line arguments are equal to <code>/?</code>. If so, it displays the help message and terminates, otherwise it executes the rest of the script code. I have tried the following:</p>
  
  <pre><code>@echo off
  FOR %%A IN (%*) DO (
    IF "%%A" == "/?" (
      ECHO This is the help message
      GOTO:EOF
    )
  )
  
  ECHO This is the rest of the script
  </code></pre>
  
  <p>This doesn't seem to work. If I change the script to:</p>
  
  <pre><code>@echo off
  FOR %%A IN (%*) DO (
    ECHO %%A
  )
  
  ECHO This is the rest of the script
  </code></pre>
  
  <p>and call it as <code>testif.bat arg1 /? arg2</code> I get the following output:</p>
  
  <pre><code>arg1
  arg2
  This is the rest of the script
  </code></pre>
  
  <p>The <code>FOR</code> loop appears be ignoring the <code>/?</code> argument. Can anyone suggest an approach to this problem that works?</p>