I am attempting to run a batch script that is to copy files from a production server (remoted in from my box say A) to a drive on Box A. This destination drive on Box A is mapped while VPNing to the prod server. I can see it from my prod server and as a small test, I can manually copy the file from the remote prod server to the mapped destination drive on Box A within my VPN session.
However my batch script can not copy the files. Even the folders All and Alphabetized are not created by the batch. Please note the batch will work correctly if I was designating the destination as a drive on the prod server itself and hence local to the batch.
Why is this so? How can I get it to work?
My batch file code:
REM Define locations of files and folders. Change the E drive and create a log and log.txt under the new drive.
REM Make sure the control file exists
if not exist "%ControlFile%" (
echo *ERROR* Control file [%ControlFile%] was not found!
REM Read each line of the control file, pass it to a subroutin for processing
for /f "usebackq tokens=1-4 delims=," %%A in ("%ControlFile%") do (
call :DoIt %%A %%B %%C %%D
) > "%LogFile%" 2>&1
REM Leave the script now
REM Subroutine to break up the control line, and then copy the file as specified
REM Make sure this file actually exists, if so copy it
if exist "%1" (
if not exist "%BaseDir%\" mkdir "%BaseDir%"
if not exist "%BaseDir%\%~4\" mkdir "%BaseDir%\%~4"
if not exist "%BaseDir%\%~4\%~3\" mkdir "%BaseDir%\%~4\%~3"
copy /Y "%1" "%BaseDir%\%~4\%~3\%~2"
if not exist "%AllDir%\" mkdir "%AllDir%"
copy /Y "%1" "%AllDir%\%~2"
) else (
echo *WARNING* Data file [%1] was not found or subfolder [%3] not created.