BAT file to copy across network

J

John Price

Hi

I'm trying to write a BAT file to copy files from one computer across
to another computer on the network. Sharing and permissions are granted
to allow read/write. Both computers running Win 7. Can copy back and
forth at will using Windows Explorer.

The content I've got so far is

CD\
xcopy c:\forcopy\*.* \\MAIN-DESKTOP\c$\forcopy1 /D /E /Y
pause

but this returns an error "Invalid drive specifiction" when I run the
BAT file containing it

I've tried changing the $ sign to a colon, but same result.

If I change the destination path to another folder on the source drive
it works fine, so it must be something about the path as it's shown
above. Or is this something that isn't possible.

What's wrong?

Many thanks

--
 
B

Bob I

Try using the "share name" of the destination folder instead of the
administrative share "\\MAIN-DESKTOP\c$\forcopy1"
 
J

JIP

Bob said:
Try using the "share name" of the destination folder instead of the
administrative share "\\MAIN-DESKTOP\c$\forcopy1"
Sorry - could you show an example of what you mean - not sure what the
share name of the folder would look like.

--
 
D

Don Phillipson

I'm trying to write a BAT file to copy files from one computer across
to another computer on the network. Sharing and permissions are granted
to allow read/write. Both computers running Win 7. Can copy back and
forth at will using Windows Explorer.

The content I've got so far is

CD\
xcopy c:\forcopy\*.* \\MAIN-DESKTOP\c$\forcopy1 /D /E /Y
pause

but this returns an error "Invalid drive specifiction" when I run the
BAT file containing it
The p.d. utility at www.xxcopy.com may meet your needs better.
Its many parameters are unusually well documented.
 
S

Stan Brown

Hi

I'm trying to write a BAT file to copy files from one computer across
to another computer on the network. Sharing and permissions are granted
to allow read/write. Both computers running Win 7. Can copy back and
forth at will using Windows Explorer.

The content I've got so far is

CD\
xcopy c:\forcopy\*.* \\MAIN-DESKTOP\c$\forcopy1 /D /E /Y
pause

but this returns an error "Invalid drive specifiction" when I run the
BAT file containing it

I've tried changing the $ sign to a colon, but same result.

If I change the destination path to another folder on the source drive
it works fine, so it must be something about the path as it's shown
above. Or is this something that isn't possible.

What's wrong?

Many thanks
You need to precede that with a NET USE command, such as

net use p: \\main-desktop\C$
xcopy c:\forcopy\*.* p:\forcopy1 /D /E /Y
:: Optional, if you want to disconnect the mapped network drive.
net use p: /d

I assume no login is required for the network folder. If it is,
change the NET USE command to
net use p: \\main-desktop\C$ * /user:MyUsername
(substituting your actual user name, of course).
 
C

charlie

Hi

I'm trying to write a BAT file to copy files from one computer across
to another computer on the network. Sharing and permissions are granted
to allow read/write. Both computers running Win 7. Can copy back and
forth at will using Windows Explorer.

The content I've got so far is

CD\
xcopy c:\forcopy\*.* \\MAIN-DESKTOP\c$\forcopy1 /D /E /Y
pause

but this returns an error "Invalid drive specifiction" when I run the
BAT file containing it

I've tried changing the $ sign to a colon, but same result.

If I change the destination path to another folder on the source drive
it works fine, so it must be something about the path as it's shown
above. Or is this something that isn't possible.

What's wrong?

Many thanks

I can think of a couple of things to try.
First complex expressions such as your networked drive might need quotes
to allow the entire expression to be used.
Next, since this is a batch file, setting the expression into a variable
might get the job done.

Another way might be to assign the network drive/sub-directory a drive
letter.

It's been more than a few years since I had to do this sort of thing
using earlier windows versions.
 
N

Nil

I'm trying to write a BAT file to copy files from one computer
across to another computer on the network. Sharing and permissions
are granted to allow read/write. Both computers running Win 7. Can
copy back and forth at will using Windows Explorer.

The content I've got so far is

CD\
xcopy c:\forcopy\*.* \\MAIN-DESKTOP\c$\forcopy1 /D /E /Y
pause

but this returns an error "Invalid drive specifiction" when I run
the BAT file containing it

I've tried changing the $ sign to a colon, but same result.

If I change the destination path to another folder on the source
drive it works fine, so it must be something about the path as
it's shown above. Or is this something that isn't possible.

What's wrong?
I tried it and got the same thing. I also have the whole drive shared
with a regular share name, \\C-Drive , and if I use that instead of the
administrative share name C$, it works as expected. Your version DOES
work when xcopying from a Win7 computer to an XP one.

Odd...
 
R

Roger Mills

Hi

I'm trying to write a BAT file to copy files from one computer across
to another computer on the network. Sharing and permissions are granted
to allow read/write. Both computers running Win 7. Can copy back and
forth at will using Windows Explorer.

The content I've got so far is

CD\
xcopy c:\forcopy\*.* \\MAIN-DESKTOP\c$\forcopy1 /D /E /Y
pause

but this returns an error "Invalid drive specifiction" when I run the
BAT file containing it

I've tried changing the $ sign to a colon, but same result.

If I change the destination path to another folder on the source drive
it works fine, so it must be something about the path as it's shown
above. Or is this something that isn't possible.

What's wrong?

Many thanks
Since forcopy1 is a folder rather than a file, don't you need a
backslash after it?

As others have said, it's a good idea to map a network drive to this
share. If you do it in Windows Explorer, and tell it to reconnect on
logon, you'll only have to do it once. So if, for example, you map Z: to
\\MAIN-DESKTOP\c$, you can set up your batch file to say:

xcopy c:\forcopy\*.* z:\forcopy1\ /D /E /Y

--
Cheers,
Roger
____________
Please reply to Newsgroup. Whilst email address is valid, it is seldom
checked.
 
F

Fokke Nauta

John Price said:
Hi

I'm trying to write a BAT file to copy files from one computer across
to another computer on the network. Sharing and permissions are granted
to allow read/write. Both computers running Win 7. Can copy back and
forth at will using Windows Explorer.

The content I've got so far is

CD\
xcopy c:\forcopy\*.* \\MAIN-DESKTOP\c$\forcopy1 /D /E /Y
pause

but this returns an error "Invalid drive specifiction" when I run the
BAT file containing it

I've tried changing the $ sign to a colon, but same result.

If I change the destination path to another folder on the source drive
it works fine, so it must be something about the path as it's shown
above. Or is this something that isn't possible.

What's wrong?

Many thanks
The xcopy command wants to see a drive letter instead of a share name. You
need to map a network drive. See the comments of Stan Brown.

Succes,

Fokke
 
J

JIP

Stan said:
You need to precede that with a NET USE command, such as

net use p: \\main-desktop\C$
xcopy c:\forcopy\*.* p:\forcopy1 /D /E /Y
:: Optional, if you want to disconnect the mapped network drive.
net use p: /d

I assume no login is required for the network folder. If it is,
change the NET USE command to
net use p: \\main-desktop\C$ * /user:MyUsername
(substituting your actual user name, of course).
Thanks Stan - when I use your first e.g. I'm asked for a username -
which it lets me input, and then asks for a network password. I'm not
aware of ever setting one, but in any event when I try to type in at
that point, it doesn't accept input from the keyboard - except for the
ENTER key - and I then get invalid password messages.

When I try the second on, it goes stiiaght to the request for a network
password, and the same thing happens - canty input from the keyboard,
and yet hitting the ENTER key moves on to the invalid password message.

Any more ideas?

JIP

--
 
B

Bob I

See NIL's reply, and look at what you named the share on the destination
PC. It may not be the folder itself, but some location above it.
 
J

JIP

John said:
Hi

I'm trying to write a BAT file to copy files from one computer across
to another computer on the network. Sharing and permissions are
granted to allow read/write. Both computers running Win 7. Can copy
back and forth at will using Windows Explorer.

The content I've got so far is

CD\
xcopy c:\forcopy\*.* \\MAIN-DESKTOP\c$\forcopy1 /D /E /Y
pause

but this returns an error "Invalid drive specifiction" when I run the
BAT file containing it

I've tried changing the $ sign to a colon, but same result.

If I change the destination path to another folder on the source drive
it works fine, so it must be something about the path as it's shown
above. Or is this something that isn't possible.

What's wrong?

Many thanks
Thanks to all - in the end, going down the route of mapping the
destination folder to a drive letter has worked. Not done that before,
so had to Google a bit first, but it's now up and running.

Very educational process, so thanks for all the input and ideas.

JIP

--
 
N

Nil

The xcopy command wants to see a drive letter instead of a share
name. You need to map a network drive. See the comments of Stan
Brown.
That's not true, as you can tell from other responses in this thread.

XCOPY works fine when the destination is a UNC name and the destination
is a subfolder of a folder in the root of the target disk. It seems to
fail when the destination is a first-level folder. This seems to happen
only on Windows 7 (I don't have a Vista machine to test right now) but
it works OK on Windows XP.

The share letter isn't required, but it's a reasonable workaround.
 
N

Nil

That's not true, as you can tell from other responses in this
thread.

XCOPY works fine when the destination is a UNC name and the
destination is a subfolder of a folder in the root of the target
disk. It seems to fail when the destination is a first-level
folder. This seems to happen only on Windows 7 (I don't have a
Vista machine to test right now) but it works OK on Windows XP.
I forgot to add that another condition for failure is that the UNC is
the administrative share (C$). If the root of the drive is shared with
a regular name (and the permissions allow it) the XCOPY will work.

I expect this is all a side effect of UAC. The OS is trying to protect
the drive's root directory.
 
F

Fokke Nauta

Nil said:
I forgot to add that another condition for failure is that the UNC is
the administrative share (C$). If the root of the drive is shared with
a regular name (and the permissions allow it) the XCOPY will work.

I expect this is all a side effect of UAC. The OS is trying to protect
the drive's root directory.
Thanks for this.

Learned a bit more.
I used to use xcopy in batch files and I always assumed that drive letters
were needed.
For me, assigning a drive letter first worked all the time.

But in this case, I guess UAC may be the problem here.
Windows 7 is a funny thing.

Fokke
 
G

Gene E. Bloch

Thanks to all - in the end, going down the route of mapping the
destination folder to a drive letter has worked. Not done that before,
so had to Google a bit first, but it's now up and running.

Very educational process, so thanks for all the input and ideas.

JIP
Thanks for letting us know.

This thread has been educational for me as well, but I do so little
network file movement that I'll probably have to relearn it all before I
use it anyway :)
 
S

Stan Brown

Thanks Stan - when I use your first e.g. I'm asked for a username -
which it lets me input, and then asks for a network password. I'm not
aware of ever setting one, but in any event when I try to type in at
that point, it doesn't accept input from the keyboard - except for the
ENTER key - and I then get invalid password messages.

When I try the second on, it goes stiiaght to the request for a network
password, and the same thing happens - canty input from the keyboard,
and yet hitting the ENTER key moves on to the invalid password message.

Any more ideas?
sorry, no. The second form of "net use" command works for me in a
similar batch file.
 
J

Jim

Fokke said:
Thanks for this.

Learned a bit more.
I used to use xcopy in batch files and I always assumed that drive letters
were needed.
For me, assigning a drive letter first worked all the time.

But in this case, I guess UAC may be the problem here.
Windows 7 is a funny thing.

Fokke
Here's what I use
--- begin bat file ---
Net use x: /DELETE
Net use x: \\Jim-Win7-PC\FWin7

xcopy "X:\Brother's Keeper 6\Data\"*.DT6 "C:\Brother's Keeper 6\Data\"
/V /-Y /D
xcopy "X:\Brother's Keeper 6\Data\Picture\"*.* "C:\Brother's Keeper
6\Data\Picture" /V /-Y /D
xcopy "X:\Brother's Keeper 6\Data\Text\"*.* "C:\Brother's Keeper
6\Data\Text" /V /-Y /D
xcopy "X:\Brother's Keeper 6\Data\Media\"*.* "C:\Brother's Keeper
6\Data\Media" /V /-Y /D
echo "=================================================="
echo About to copy Chaminade 1964 data"
echo "=================================================="
xcopy "X:\Brother's Keeper 6\Chaminade 1964\"*.DT6 "C:\Brother's Keeper
6\Chaminade 1964\" /V /-Y /D
xcopy "X:\Brother's Keeper 6\Chaminade 1964\Picture\"*.* "C:\Brother's
Keeper 6\Chaminade 1964\Picture" /V /-Y /D
xcopy "X:\Brother's Keeper 6\Chaminade 1964\Text\"*.* "C:\Brother's
Keeper 6\Chaminade 1964\Text" /V /-Y /D
xcopy "X:\Brother's Keeper 6\Chaminade 1964\Media\"*.* "C:\Brother's
Keeper 6\Chaminade 1964\Media" /V /-Y /D
Net use x: /DELETE
pause

--- end bat file --

When I use it it asks for a user name and password of my windows 7 box
and I use the same one I use to log on to it.

This copies my genealogy files from my desktop to my laptop.

Hope this helps

Jim
 
J

JIP

Gene said:
across >> to another computer on the network. Sharing and permissions
are >> granted to allow read/write. Both computers running Win 7. Can
copy >> back and forth at will using Windows Explorer.
drive >> it works fine, so it must be something about the path as
it's shown >> above. Or is this something that isn't possible.

Thanks for letting us know.

This thread has been educational for me as well, but I do so little
network file movement that I'll probably have to relearn it all
before I use it anyway :)
I spend my life having to relearn things - due to the Age Related
Memory Deficiency Syndrome. But at least I never get to see the same
film twice!!

--
 
G

Gene E. Bloch

I spend my life having to relearn things - due to the Age Related
Memory Deficiency Syndrome. But at least I never get to see the same
film twice!!
I take notes.

If only I could remember to use them...
 

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