title: Problems working with different drive units in a batch file
body: <p>This is my first batch file, and also my first time with batch language (I usually use UNIX and don't know a lot about Windows commands).</p>
  
  <p>I'm creating a batch file called <code>install.bat</code> which does all the work to install a Java application from source files. Here a snapshot of the install section:</p>
  
  <pre><code>@ECHO off
  SET INSTALL_DIR=%1\
  SET SRC_DIR=sources\
  SET LIB_DIR=lib\
  SET IMG_DIR=img\
  SET BIN_DIR=bin\
  SET INIT_DIR=%CD%
  SET MAIN_CLASS=%SRC_DIR%\main\Main.java
  SET CLASS_PATH=%LIB_DIR%log4j.jar;%LIB_DIR%jdom.jar;
  SET JAR_NOM=myApp.jar
  SET JAR_MF=MANIFEST.MF
  
  :BEGIN
  CLS
  ECHO Checking directory...
  IF EXIST %INSTALL_DIR% (
      GOTO Ask_Overwrite 
  ) ELSE (
      GOTO Install
  )
  
  :Ask_overwrite
  SET OVERW=Y
  SET /P OVERW="The program is already installed. Overwrite? ([Y]/N): "
  IF %OVERW%==N GOTO Cancel
  IF %OVERW%==n GOTO Cancel
  IF %OVERW%==Y (
      RD /S /Q %INSTALL_DIR% &lt;--- Here was the error
      GOTO Install
  )
  IF %OVERW%==y (
      RD /S /Q %INSTALL_DIR% &lt;--- Here was the error
      GOTO Install
  )
  GOTO Ask_overwrite
  
  :Install
  MD %INSTALL_DIR%   
  XCOPY . %INSTALL_DIR% /E
  CD /D %INSTALL_DIR%
  MD %BIN_DIR%
  
  ECHO Compiling...
  javac -cp %CLASS_PATH% -sourcepath %SRC_DIR% %MAIN_CLASS% -d %BIN_DIR%
  
  ECHO Creating JAR file...
  jar cfm %JAR_NOM% %JAR_MF% -C %BIN_DIR% .
  
  ECHO Succes! The application has been installed in %INSTALL_DIR%
  GOTO CleanUp
  
  :Abort
  ECHO Abort! The application has not been installed.
  GOTO CleanUp
  
  :Cancel
  ECHO Canceled by user. The application has not been installed.
  GOTO END
  
  :Cleanup
  REM Code for clean up
  GOTO END
  
  :END
  CD /D %INIT_DIR%
  PAUSE
  </code></pre>
  
  <p>NOTE: The javac and jar commands are correct, at least work in my machine.</p>
  
  <p>Well, the script works correctly when I test it with the <code>INSTALL_DIR</code> belonging to the same drive where I execute it, but if I use a target directory out of the drive where I'm executing, I have problems.</p>
  
  <p>Executions without problems (called in a cmd.exe session):</p>
  
  <p><code>C:\Users\TC\testInstall&gt; install.bat .\..\installTarget</code></p>
  
  <p><code>C:\Users\TC\testInstall&gt; install.bat C:\Users\TC\installTarget</code></p>
  
  <p>Execution with problems (called in a cmd.exe session):
  <code>C:\Users\TC\testInstall&gt; install.bat D:\Documents\installTarget</code></p>
  
  <p>The problems happen when I try to copy files specially, but also making and removing directories.</p>
  
  <p>I hope someone can tell to me which options I must use in order to fix the problems.</p>
  
  <p>Regards!</p>