Solved

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

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

Free book by J.Peter Bruzzese, Microsoft MVP

Are you using Office 365? Trying to set up email signatures but you’re struggling with transport rules and connectors? Let renowned Microsoft MVP J.Peter Bruzzese show you how in this exclusive e-book on Office 365 email signatures. Better yet, it’s free!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
upgrade Vcenter to V6 10 83
Alternative access for remote users 6 85
What is this Task? 4 85
Windows Server 2003 Policy Preventing Updates 6 18
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…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now