Solved

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

Posted on 2007-11-21
4
1,621 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
Comment Utility
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
Comment Utility
0
 
LVL 2

Assisted Solution

by:SwassLikeMe
SwassLikeMe earned 100 total points
Comment Utility
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
Comment Utility
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

Why spend so long doing email signature updates?

Do you spend loads of your time carrying out email signature updates? Not very interesting are they? Don’t let signature updates get you down. Let Exclaimer Cloud - Signatures for Office 365 make managing email signatures a breeze.

Join & Write a Comment

Suggested Solutions

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…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
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…
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…

772 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

16 Experts available now in Live!

Get 1:1 Help Now