Help creating xcopy batch file??

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
bbugyi200
Posts: 4
Joined: 16 Jul 2013 18:30

Help creating xcopy batch file??

#1 Post by bbugyi200 » 16 Jul 2013 18:36

I'm trying to create a script to copy a file to a backup drive.. This is what I'm using:

@echo off
xcopy source destination /c /d /h /i /k /q /r /s /x /y

It doesn't seem to be working. I'm really new to this. Can someone help me??

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Help creating xcopy batch file??

#2 Post by penpen » 16 Jul 2013 18:47

If source is a directory, and
destination is a directory too, or not existing, and
your batch is in the right directory,
then this code should work well.

Maybe you rem out the @echo off line, and see what error message will be displayed.

penpen

bbugyi200
Posts: 4
Joined: 16 Jul 2013 18:30

Re: Help creating xcopy batch file??

#3 Post by bbugyi200 » 16 Jul 2013 18:56

I have a feeling that it is something stupid that I am overlooking. All I did was type this up in a notepad document, save it with a .bat extension, and then try to open it through windows explorer. When I do, I see a command prompt pop up briefly and then disappear. Nothing seems to copy or change. I know the actual xcopy command is good because I've tried it in the command prompt and it works fine.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help creating xcopy batch file??

#4 Post by foxidrive » 16 Jul 2013 19:00

Open a cmd prompt and 'cd' to your bat folder and type in the bat name. You will see the error message then.

bbugyi200
Posts: 4
Joined: 16 Jul 2013 18:30

Re: Help creating xcopy batch file??

#5 Post by bbugyi200 » 16 Jul 2013 19:11

I just ran it from command line like you asked. This is the error:

Access denied
0 files copied

Because it's not running as admin I'm assuming?? how do I fix it? This is windows 8 by the way. I'm not sure if that's relevant.

bbugyi200
Posts: 4
Joined: 16 Jul 2013 18:30

Re: Help creating xcopy batch file??

#6 Post by bbugyi200 » 16 Jul 2013 19:51

I just discovered the fix. By checking, "Run with highest privileges", in task scheduler I was able to make it run as admin. This worked beautifully. Thanks guys.

Post Reply