title: Batch "If was unexpected at this time"
body: <p>I'm trying to write a simple batch file to run the Tracert command, and the user can input if he wants a list of local devices to trace, in which case userResponse equals y, or if he doesn't, in which case it equals n. When I launch the application, the prompt to enter y or n appears and no matter what I write, the error message "if was unexpected at this time appears" and the screen quickly closes. After browsing Stack Overflow for a while, I tried the following fixes :</p>
  
  <ul>
  <li>Putting the text of the user inputs between quotes.</li>
  <li>Adding <code>SETLOCAL ENABLEDELAYEDEXPANSION</code></li>
  </ul>
  
  <p>But none of those solutions worked.</p>
  
  <p>Here's the code.</p>
  
  <pre><code>@echo off
  color A
  title Trace Route
  SETLOCAL ENABLEDELAYEDEXPANSION
  
  set /p userResponse="Would you like a list of local devices to trace (y/n)? "
  
  if %userResponse%==y (
  
  net view
  
  set /p IPAddress="Enter the IP address that you would like to trace: " 
  echo.
  set /p addressType="Enter the IP Address type (4 or 6): "
  
  tracert -%addressType% %IPAddress%
  
  PAUSE
  
  ) if %userResponse%==n (
  
  set /p IPAddress="Enter the IP address that you would like to trace: " 
  echo.
  set /p addressType="Enter the IP Address type (4 or 6): "
  
  tracert -%addressType% %IPAddress%
  
  PAUSE
  )
  </code></pre>
  
  <p>I'm a beginner to Stack Exchange, so forgive me if any information is missing. I'll quickly add it on request.</p>
  
  <p>Thanks!</p>