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
614 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 52

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 52

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
 
LVL 52

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 69

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 52

Expert Comment

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

786 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