Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-11-21
4
Medium Priority
?
1,627 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Assisted Solution

by:AnthonyP9618
AnthonyP9618 earned 400 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 400 total points
ID: 20331552
0
 
LVL 2

Assisted Solution

by:SwassLikeMe
SwassLikeMe earned 400 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 800 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
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). …
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…
Suggested Courses

704 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