Solved

Batch writing out to another remotely mapped computer drive

Posted on 2014-03-14
3
277 Views
Last Modified: 2014-03-27
Hello EEE,

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:

@echo off

REM Define locations of files and folders. Change the E drive and create a log and log.txt under the new drive.
set ControlFile=batch_input.txt
set BaseDir=E:\Alphabetized
set AllDir=E:\All
set LogFile=E:\logs\log.txt

(

 REM Make sure the control file exists
  if not exist "%ControlFile%" (
    echo *ERROR* Control file [%ControlFile%] was not found!
    exit /b
  )  

 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
exit /b

REM Subroutine to break up the control line, and then copy the file as specified
:DoIt

  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.
  )
 


 exit /b
0
Comment
Question by:LuckyLucks
3 Comments
 
LVL 27

Accepted Solution

by:
Steve earned 500 total points
ID: 39931195
Not entirely sure i undersrand your query.
Are you coping files from E: to. E:?
What part does the vpn play in this?

Does the batch file work if run manually or are you trying to schedule it?
0
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 39932041
Try commenting out the beginning @Echo Off. That will make the batch file echo/display each line on the console as it gets executed. Is the "If not exist ... mkdir ..." line echoed back correctly?
0
 

Author Closing Comment

by:LuckyLucks
ID: 39959479
Not sure if this is it. Had something to do with RDP
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ncftpget copy files from remote server to my local drive 4 51
Batch script to delete folder content 3 98
Combine multiple text files into one file 4 50
MailSend Attachments 41 168
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question