Solved

Why the script cannot copy a file from one server to another server?

Posted on 2007-11-21
4
1,625 Views
Last Modified: 2012-08-14
Hi:

I'd like to create a simple scheduled task which copies a file from one server, say A, to another server say B. Assumed that on A, the file is in A1\DATA\file1 and I would like to copy to B inot the folder B1\DATA\file1

I already shared the the folder B1so that with the same account log in on A, that account ahs full control of B1.

I've tested do manually copy file 1 from A to B and it works correctly.

Then I write a text file (using note pad) with the following content:

//=========
@echo off
set Source=A1:\DATA\File1
set Target=B1:\DATA\File1
copy "%Source%" "%Target%"
//========

Then I create a scheduled task (control panel --> Scheduled Task --> ...)

And I run the task to test but the task does not copy the file from A to B as expected.

Do you know what causes this problem.

Thanks a lot.

Somits
0
Comment
Question by:somits
4 Comments
 
LVL 11

Assisted Solution

by:AnthonyP9618
AnthonyP9618 earned 100 total points
ID: 20331510
Try mapping the drives then try the copy... For example:

//=========
@echo off
set Source=F:\DATA\File1
set Target=E:\DATA\File1
copy "%Source%" "%Target%"
//========

Where the F drive is a folder mapped to server A1 and the E drive is a folder mapped to server A2.
0
 
LVL 8

Assisted Solution

by:rjwesley
rjwesley earned 100 total points
ID: 20331552
0
 
LVL 2

Assisted Solution

by:SwassLikeMe
SwassLikeMe earned 100 total points
ID: 20331664
Use a UNC path.  The way to do this is:

\\servername\sharename\directoryname\filename.ext

So for example
set Source="\\server\data\file1"
set Dest="\\server\data\file2"
0
 
LVL 6

Accepted Solution

by:
Wallsy earned 200 total points
ID: 20333206
If you're running this as a scheduled task with the SYSTEM account it will not have access to the remote drive. You need to either:
Run the scheduled task as the account with the rights.
Copy C:\Path\ToFiles \\Server\Share\Path\ToFiles
or
Run the scheduled task as the SYSTEM account and add a line to map the drive on the other server
Net Use Z: \\Server\Share /u:DomainOrServer\Account Password
Copy C:\Path\ToFiles Z:\PathToFiles
Net Use Z: /d

You may also want to investigate using xcopy or robocopy to copy multiple files in a directory structure.

HTH,

Wallsy
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Some time ago I faced the need to use a uniform folder structure that spanned across numerous sites of an enterprise to be used as a common repository for the Software packages of the Configuration Manager 2007 infrastructure. Because the procedu…
INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

726 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