xcopy using batch file

G

Guest

I am trying to copy all files and folders from a directory on my computer to
one on the server. The xcopy command I am using is:

xcopy /s /e /d /y c:\xcopy \\server01\users\niae\mydocu~1

exit

This works a treat if I type it in or copy and paste it from Notepad.
However, when I save it as a .bat file on to my desktop and try running it it
does not work. All that happens is that the command line just endlessly
scrolls up the dos window.
Any ideas?
 
P

Pegasus \(MVP\)

Logie Bear said:
I am trying to copy all files and folders from a directory on my computer to
one on the server. The xcopy command I am using is:

xcopy /s /e /d /y c:\xcopy \\server01\users\niae\mydocu~1

exit

This works a treat if I type it in or copy and paste it from Notepad.
However, when I save it as a .bat file on to my desktop and try running it it
does not work. All that happens is that the command line just endlessly
scrolls up the dos window.
Any ideas?

I supect you like the word "xcopy" too much. You already have
a folder called "c:\xcopy", which is not a particularly good idea,
and you most likely called your batch file "xcopy.bat". Never
call a batch file by the name of a system tool - it's a recipe for
disaster! Call it "MyXcopy.bat" if you like.
 
G

Guest

I have changed the name of my folder and the .bat file as suggested but still
experiencing the same problem.
 
P

Pegasus \(MVP\)

I can't see your machine but I bet that you still have a file
called "xcopy.bat" somewhere. You can easily prove it by
modifying your code like so:

%SystemRoot%\system32\xcopy.exe /s /e /d /y c:\xcopy
\\server01\users\niae\mydocu~1\

Note also the trailing backslash.
 
G

Guest

Thank you very. Sorted now.

Pegasus (MVP) said:
I can't see your machine but I bet that you still have a file
called "xcopy.bat" somewhere. You can easily prove it by
modifying your code like so:

%SystemRoot%\system32\xcopy.exe /s /e /d /y c:\xcopy
\\server01\users\niae\mydocu~1\

Note also the trailing backslash.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top