How to copy a file from a network share to a local folder - scheduled automatically

sah18 used Ask the Experts™
I'd like to somehow schedule a file (access database .mdb file) to be copied from a network share to a local folder on the C drive.  I want this to copy to run on a regular basis (possibly every day, or perhaps each time a user logs in), so that the copy is relatively current.

The network share is restricted to only certain users, so a user does need to be logged in (or identified) in order to copy the access db.

We are working with all Windows systems.  The local systems are all running Windows XP SP3.  Users log in with domain accounts.

I'm not sure how to setup something to run on a regular basis for this purpose.  Any suggestions would be welcome!

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You could write a batch (bat) file to copy the file and then run it using the Task Scheduler. If you let me know the full path where the file is being copied from and the full path you'd like it copied to, I'll give you some code you can save as a batch file. Once this is done, take a look at this Microsoft article on how to configure the Task Scheduler in Windows XP:-

You should be able to accomplish this with Robocopy ( and a scheduled task in Task Scheduler.

If you create a reconencting network drive with log-on credentials, you should be able to cover the login problem.

Here is another location with some helpful information about Robocopy

What version of Powershell are you using? 1 or 2?
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Robert Sutton JrSenior Network Manager

Just open a new Notepad session, and input the following lines:

copy <FullSourcePath>\filename <FullDestinationPath>

Save it as 'copy.bat' or whatever name you wish. Then, add a new scheduled task, when it prompts you what app to run, Browse and select your saved batch file. Then simply tell the Task Scheduler when you want it done.
You should test it before scheduling, as the above command will run it and you'll want to ensure pathname accuracy.
Alternately, you can just put the batch file in your startup folder in Windows on the PC you want to run the task.

Hope this helps.

im pretty sure that you can create a batch file for this to work so here's an article that gives you one that is very similar to want you're asking for:

I hope it helps!!!


I have a couple questions about the above suggestions:

1) If a user isn't logged in at the time the batch file is scheduled to run, how can we still get it to run?  Since the user needs to be authenticated (and mapped) to the share location, I'm unclear how this would work.

2)  I've never used powershell, but thought it might be a way to accomplish this.  I'm not even sure how to find it or run it, so I don't know what version it would be.

3) If I place the batch file in the startup for any user just logging in, that seems the most logical solution (as The Warlock mentioned), but I'm concerned that the domain login script (the one that does the drive mapping) won't be completed prior to this batch file attempting to run.  Is there a way to delay the batch from running immediately??  Or can a delay be written into the batch as the first line, or is there a way to test if the "S" drive exists, before doing the copy?

Thanks much for all suggestions!
Danny ChildIT Manager

Many backup tools offer the ability to run scripts on when they start or finish...  eg ArcServe, BackupExec, and so on.
You could add the The Warlock's one-liner in there, so the copy is done whenever your backup runs - daily, I hope!

If you use full UNC paths - eg \\servername\share\folder - then you don't need to worry about mapped drives (most backup tools have pretty elevated permissions so they can get to all folders anyway).
My thought was to have the batch file passing credentials to map the drive and then un-mapping it when done, using roughly this method:-

Step 1: net use z: \\server\share password /user:domain\username /persistent
Step 2:copy c:\folder\file.txt z:\folder\file.txt
Step 3:net use /delete z:

This does however mean that you'll have a batch file sitting there with a username and password in it for all to see, which does present some problems. However, if a basic user was created with minimal permissions, any potential impact could be limited.
Create a .ps1 (Powerhsell script) with this information below and save it as Copy-Mdb.ps1 on a network share you can access from all your machine.
copy -Path ''\\Yourshare\yourfolder\yourfile.mdb" -Destination "C:\yourfolder"

Open in new window

When you create the scheduled task create it with a user account that has the appropriate privilieges.  Under the Run textbox enter the appropriate information:
C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "\\somenetworkshare\Scripts\Daily\Copy-Mdb.ps1" -NoProfile -WindowStyle "Hidden"

Open in new window

By saving scripts to a commonly accessible share you save yourself the trouble of having to put the script on multiple machines.  Additionally, you can refer to powershell -? in any shell to get more details on the switches available to starting powershell.exe.

I'm amazed nobody mentioned setting up a login script. Very simple, create a GPO that targets all of the specific groups/users and then point them to a login script to copy the file over. Below is a sample script you can use to accomplish the task
copy \\server\share\example.mdb c:\database\example.mdb /Y

Open in new window


I apologize for not replying back sooner.  I have been swamped and have not yet had a chance to try any of your suggestions.  I'm hoping to get back to this issue in the next week & will provide feedback then.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial