Solved

How to create a batch file to copy PDF's from one drive to another drive on my server?

Posted on 2014-01-17
8
612 Views
Last Modified: 2014-02-10
I created a batch file on my server to copy PDF's from the C drive to a mapped drive. However, it isn't working. When i change the mapped drive to the D drive (thats not a mapped drive), my script works...it just doesn't work on a mapped drive. How do I get this to work so it will copy to my mapped drive? I read somewhere that if you move files to a mapped drive, the script needs to be a little different. Here's what i have:

@echo off
:: variables
set drive=F:\Quotes
set folder=%date:~10,4%_%date:~4,2%_%date:~7,2%
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ### Backing up directory...
%backupcmd% "C:\Program Files (x86)\QuoteHistory" "%drive%\%folder%"

How do I make this work to take the quotes from the C drive and make a copy onto the mapped F drive? Thanks!!!
0
Comment
Question by:brasiman
8 Comments
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39790022
Your script works fine on a mapped drive here – tried it on a mapped network drive and no problems. So it must be something related to your mapped drive or network or permissions. I see that you're using the /K option, which copies attributes. Maybe your mapped drive doesn't like that – try it without that option. Also, what happens if you manually issue the xcopy command in a command prompt? If it doesn't work in a normal command prompt, how about an elevated command prompt? Regards, Joe
0
 
LVL 30

Expert Comment

by:pgm554
ID: 39790072
2nd the elevated command prompt.
0
 

Author Comment

by:brasiman
ID: 39790696
Thanks Joe and pgm554 for your replies!

I will try taking out the /K. Good suggestion. I'm a rookie at this stuff. :)

As far as the elevated command prompt, how do you do that? I have this batch file, then have setup the Task Scheduler to run this once a week.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39790722
Let's make sure that an elevated prompt solves the problem. To do this:

Start Menu
All Programs
Accessories
Right-click on Command Prompt
Run as administrator

Let me know if that works and then I'll walk you through how to do it in Task Scheduler. Regards, Joe
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 51

Assisted Solution

by:Joe Winograd, EE MVE
Joe Winograd, EE MVE earned 250 total points
ID: 39791101
I haven't heard back from you and I'm going offline for a few hours, so here's how to run elevated in Task Scheduler. Someone set up the Task Scheduler to run your batch file once a week. So, run Task Scheduler. There are many ways to do it...here's one:

Start Menu
All Programs
Accessories
System Tools
Task Scheduler

You will see this in the upper left:

Task SchedulerClick the triangle pointed to by the red arrow above to expand the library. Keep clicking the triangles and clicking the libraries in the left pane until you see the task with your batch file in the top right pane. Then highlight that task and double-click it, which opens it for editing. You'll see something like this:

yourtaskTick the box that says [Run with highest privileges], as pointed to by the red arrow above (click OK to save the change). That will run the batch file elevated. I'll check back into this thread when I return in a few hours to see how you're doing. Regards, Joe
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 250 total points
ID: 39792325
Also note that you might not be able to rely on "F:" being available in the task (depends on a lot of factors). Try if using the UNC path \\server\share\... instead works.
0
 

Author Comment

by:brasiman
ID: 39804751
I elevated the permissions and we will see if it works. I will try that shortly. Thanks!
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39804781
You're welcome! Looking forward to hearing your results.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now