PC Review


Reply
Thread Tools Rate Thread

Bat file to copy files from one computer to another

 
 
jsaumer@gmail.com
Guest
Posts: n/a
 
      5th Apr 2007
Hello,

I am wondering how to do the following:

Copy all the files in a difrectory to a remote directory, overwriting
any files already there.

There will need to have domain authentication built in, and it needs
to do it wihtout prompting the user because it will be a scheduled
task.

Any and all help will be greatly appreciated!

 
Reply With Quote
 
 
 
 
Herb Martin
Guest
Posts: n/a
 
      5th Apr 2007

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I am wondering how to do the following:
>
> Copy all the files in a difrectory to a remote directory, overwriting
> any files already there.


xcopy Source Destination /y

/y means to overwrite.

You can add /D to only overwrite with newer files.

And /s to do subdirectories.

And /r /h to include Read-Only (bit set) or Hidden files.

/c to continue on errors if one or some files fail (due to locking etc.)

> There will need to have domain authentication built in, and it needs
> to do it wihtout prompting the user because it will be a scheduled
> task.


If authentication by the current "user" or "Computer" is already possible
the above just works:

xcopy Source \\Server\Destination /y

Or you can map the drive.

The key is that the process which runs the batch must be able to
authenticate
and have enough permission to do the task.

When you schedule a submitted batch file (Task Scheduler) you are allowed
to provide credentials (user name and password) for running the batch.

If you use a Computer account (startup batch or scheduled job) then the
COMPUTER account is the one that must have access with both the
SHARE and the NTFS permissions on the server.

> Any and all help will be greatly appreciated!


Let us know if you have more quesitons or don't understand something....

--
Herb Martin, MCSE, MVP
http://www.LearnQuick.Com
(phone on web site)


 
Reply With Quote
 
jsaumer@gmail.com
Guest
Posts: n/a
 
      5th Apr 2007
On Apr 5, 10:05 am, "Herb Martin" <n...@learnquick.com> wrote:
> <jsau...@gmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
> > Hello,

>
> > I am wondering how to do the following:

>
> > Copy all the files in a difrectory to a remote directory, overwriting
> > any files already there.

>
> xcopy Source Destination /y
>
> /y means to overwrite.
>
> You can add /D to only overwrite with newer files.
>
> And /s to do subdirectories.
>
> And /r /h to include Read-Only (bit set) or Hidden files.
>
> /c to continue on errors if one or some files fail (due to locking etc.)
>
> > There will need to have domain authentication built in, and it needs
> > to do it wihtout prompting the user because it will be a scheduled
> > task.

>
> If authentication by the current "user" or "Computer" is already possible
> the above just works:
>
> xcopy Source \\Server\Destination /y
>
> Or you can map the drive.
>
> The key is that the process which runs the batch must be able to
> authenticate
> and have enough permission to do the task.
>
> When you schedule a submitted batch file (Task Scheduler) you are allowed
> to provide credentials (user name and password) for running the batch.
>
> If you use a Computer account (startup batch or scheduled job) then the
> COMPUTER account is the one that must have access with both the
> SHARE and the NTFS permissions on the server.
>
> > Any and all help will be greatly appreciated!

>
> Let us know if you have more quesitons or don't understand something....
>
> --
> Herb Martin, MCSE, MVPhttp://www.LearnQuick.Com
> (phone on web site)


It works like a charm! Thanks!

To keep from overwhelming the remote server with a ton of SQL backups,
is there a way for the bat to delete everything in the remote fodler
without prompting the user if they are sure?

 
Reply With Quote
 
Herb Martin
Guest
Posts: n/a
 
      5th Apr 2007

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> To keep from overwhelming the remote server with a ton of SQL backups,
> is there a way for the bat to delete everything in the remote fodler
> without prompting the user if they are sure?


Yes and VERY dangerous unless YOU are sure:

del /q FilesToDelete

You could do an "if exists" test to make sure you got the copy:

if exists \\Server\Dest\Filename del localPath\Filename

You can also cycled through the local file names with a For-In-Do
loop (double % signs needed for this to run in a batch, single if
you run it interactively to test):

cd LocalDirectory
for %%a in (*.*) do if exist "\\Server\Share\%%a" del "%%a"


--
Herb Martin, MCSE, MVP
http://www.LearnQuick.Com
(phone on web site)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Copy Issues Computer to Computer Windows Vista File Management 1 27th Apr 2009 06:15 PM
I am looking for a file copy program that will simply copy files without stopping LarryB Windows XP 6 8th Mar 2007 08:24 PM
How do I copy all Excel files from old computer to new computer? =?Utf-8?B?UmZhcnNo?= Microsoft Excel Misc 2 20th Dec 2005 03:23 AM
using File.Copy to copy files to shared hosting site Steve Richter Microsoft ASP .NET 4 18th Apr 2005 04:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:26 AM.