title: How to change current working directory using a batch file
body: <p>I need some help in writing a batch file.
  I have a path stored in a variable root as follows:</p>
  
  <pre><code>set root=D:\Work\Root
  </code></pre>
  
  <p>Then I am changing my working directory to this root as follows:</p>
  
  <pre><code>cd %root%
  </code></pre>
  
  <p>When I execute this batch file from anywhere on the D drive this is done successfully. But when I execute the same batch file from some other drive, cd %root% doesn't work.</p>
  
  <p>Is there a way I can get the drive letter from the root variable? I can then change the current directory to this drive first and then cd %root% shall work.</p>