Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
629 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 56

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 56

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 56

Assisted Solution

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

Accepted Solution

by:
Qlemo earned 1000 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 56

Expert Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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 modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

877 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