title: Windows batch string comparison in if statement wrong?
body: <p>i try to write a tiny batch file which shall react in different way dependent on a parameter.
  Unfortunately the "if" statement whch compares 2 strings seem not to work as expected.
  The code used is:</p>
  
  <pre><code>@echo off
  if "%1"=="" goto Usage
  echo "Parameter: %1"
  IF /I "%1"=="START" {
     echo "Why the hell is %1 == Start?"
     SET Parameter=start
     goto :execute
  } else if /I "%1"=="STOP" {
     SET Parameter=stop
     goto :execute
  }
  echo "Parameter %1% invalid"
  
  :Usage
  echo "Synapsis:"
  echo "   SwitchServices Start|Stop"
  goto :EOF
  
  :execute
  SET servicename=Dnscache
  SET filename=Dnscache.exe
  CALL :%parameter%_Service
  goto :EOF
  
  :stop_Service
  echo ... stopping service ...
  net stop %servicename%
  if (ERRORLEVEL GTR 0) call :kill_Service
  sc config %servicename% start= disabled
  Service stopped.
  exit /b
  
  :kill_Service
  taskkill /f /IM %filename%
  exit /b
  
  :start_Service
  echo ... starting service ...
  sc config %servicename% start= auto
  net start %servicename%
  exit /b
  
  :EOF
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>c:\Users\kollenba\Documents\Temp&gt;KapschServices.cmd xxx
  "Parameter: xxx"
  "Why the hell is xxx == Start?"
  ... starting service ...
  [SC] ChangeServiceConfig ERFOLG
  Der angeforderte Dienst wurde bereits gestartet.
  </code></pre>
  
  <p>I do not understand why the condition</p>
  
  <pre><code>if /I "%1"=="START"
  </code></pre>
  
  <p>does not work as expected.
  Any hints?</p>
  
  <p>Precondition: the batch file must be executed with administrator permissions to allow the "net start" command.
  Used OS: Windows 7</p>