title: Batch File: Syntax for IF ELSE
body: <p>I have an old Windows Server 2000 server in my environment that will not authenticate against server 2012 DCs. While we get this Server Upgraded I have to ensure that it always points at a Server 2008 R2 DC. The best solution I have come up with is a basic batch file that I will run every 5 mins (scheduled task) to first check the DC that it is pointing at and change it if necessary. I would also like to log these to a text file stamped with time and date</p>
  
  <p>I know the script I want to write but have no idea of the Syntax to use for IF ELSE in a batch file. You can ignore what the command is actually doing I'm more interested in the syntax</p>
  
  <p>I have attempted to write the script in JavaScript</p>
  
  <pre><code>if(nltest /server:ServerName123 /sc_query:branch === DCName01) 
  {
  \\I would like it to do nothing apart from write to a text file that it succeeded
  
      Print to a text file ("Ponting to DCNAME01 with time and date");
  {
  else
  {
  \\I would like it to run the following command to point the server to the correct DC
  
  nltest /server:ServerName123 /sc_reset:branch\DCName01;
  Print to a text file "("Changed to DCNAME01 with time and date");
  }
  </code></pre>
  
  <p>thanks</p>