Solved

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

Posted on 2007-11-21
4
1,623 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Learn about cloud computing and its benefits for small business owners.
Know what services you can and cannot, should and should not combine on your server.
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…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

810 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