title: Batch file using If statement and keyboard input
body: <p>A slightly late Happy New Year to everyone, hope you had a good one.</p>
  
  <p>I'm trying to create a batch file that will take keyboard input and then either launch a program based on that input or display an error message if the option entered isn't valid.  But it's not working.  Here's what I've got so far:</p>
  
  <pre><code>ECHO OFF
  set /p %environment%=Connect to Live or Dev?:
  
  IF %environment% = "Live" 
  (
  C:\Windows\System32\runas.exe /user:live\someuser /netonly "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe"
  ) 
  ELSE IF %environment% = "Dev" 
  (
  C:\Windows\System32\runas.exe /user:dev\someuser /netonly "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe"
  ) 
  ELSE 
  (
  ECHO "Invalid Option"
  )
  </code></pre>
  
  <p>I've tried it with and without the % round the variable but it didn't work.  Can anyone point me in the right direction?</p>
  
  <p>Hope you can help.</p>
  
  <p>Cheers</p>
  
  <p>Alex</p>