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
622 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
[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
8 Comments
 
LVL 54

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 54

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
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 54

Assisted Solution

by:Joe Winograd, EE MVE 2015&2016
Joe Winograd, EE MVE 2015&2016 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 70

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 54

Expert Comment

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

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
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…

627 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