[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

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

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!

0
sah18
Asked:
sah18
  • 2
  • 2
  • 2
  • +5
2 Solutions
 
Steve GouldCommented:
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:-

http://support.microsoft.com/kb/308569
0
 
SarcastCommented:
You should be able to accomplish this with Robocopy (http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=17657) 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
http://theos.in/windows-server/free-download-windows-xp-2003-robocopy-software/
0
 
wls3Commented:
What version of Powershell are you using? 1 or 2?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Robert Sutton JrSenior Network ManagerCommented:
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.
0
 
eddymelCommented:
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:

http://www.pcreview.co.uk/forums/do-schedule-automatic-file-copy-t493716.html

I hope it helps!!!
0
 
sah18Author Commented:
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!
0
 
Danny ChildIT ManagerCommented:
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).
0
 
Steve GouldCommented:
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.
0
 
wls3Commented:
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.
0
 
joeyfazCommented:
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

0
 
sah18Author Commented:
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.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
  • 2
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now