Solved

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

Posted on 2011-09-02
12
329 Views
Last Modified: 2012-05-12
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
Comment
Question by:sah18
[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
  • 2
  • 2
  • 2
  • +5
12 Comments
 
LVL 3

Expert Comment

by:Steve Gould
ID: 36473409
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
 
LVL 2

Expert Comment

by:Sarcast
ID: 36473429
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
 
LVL 10

Expert Comment

by:wls3
ID: 36473437
What version of Powershell are you using? 1 or 2?
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 15

Expert Comment

by:Robert Sutton Jr
ID: 36473474
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
 
LVL 1

Expert Comment

by:eddymel
ID: 36473513
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
 
LVL 9

Author Comment

by:sah18
ID: 36474375
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
 
LVL 23

Expert Comment

by:Danny Child
ID: 36474496
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
 
LVL 3

Accepted Solution

by:
Steve Gould earned 300 total points
ID: 36474612
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
 
LVL 10

Assisted Solution

by:wls3
wls3 earned 200 total points
ID: 36475174
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
 
LVL 6

Expert Comment

by:joeyfaz
ID: 36478700
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
 
LVL 9

Author Comment

by:sah18
ID: 36546728
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

737 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