title: Conditional statements in batch files
body: <p>Is it possible to have conditional statements in batch scripts?</p>
  
  <p>For example:</p>
  
  <p>I have two servers, S1 and S2.When the batch file is deployed in S1 then the output should be generated in location L1. Likewise if the batch file is deployed in S2 then output should be generated in location L2.</p>
  
  <p>My script:</p>
  
  <pre><code>set ComputerName=S1
  set RepServer=%ComputerName%
  set DBServer=%ComputerName%
  set ReportPath="/DEV/Clearviewbilling"
  set SharedPath=\\scottvdr1\ClearviewBilling\DEV-TEST
  set UserId=-E
  set fn=Create_Log.txt
  
  if exist %fn% del %fn%
  @echo on
  
  @rem Reports
  rs -i "%CD%"\Reports\Create_Sub.rss -s http://%RepServer%/reportserver -v Path=%SharedPath% -v rootpath=%ReportPath% -v DBServer=%DBServer% -t  &gt;&gt;  %fn% 2&gt;&amp;1
  </code></pre>
  
  <p>But i want the script to be:</p>
  
  <pre><code>set ComputerName=S1
  set RepServer=%ComputerName%
  set DBServer=%ComputerName%
  
  If ComputerName=S1
  Set SharedPath=//blah/blah
  else
  Set sharedPath=//some/path
  
  set ReportPath="/DEV/Clearviewbilling"
  set UserId=-E
  set fn=Create_Log.txt
  
  if exist %fn% del %fn%
  @echo on
  
  @rem Reports
  rs -i "%CD%"\Reports\Create_Sub.rss -s http://%RepServer%/reportserver -v Path=%SharedPath% -v rootpath=%ReportPath% -v DBServer=%DBServer% -t  &gt;&gt;  %fn% 2&gt;&amp;1   
  </code></pre>
  
  <p>Hence when the file is deployed, the reports are generated in the required path. But this is not working.</p>