Problem transferin files using batch file

iscivanomar
iscivanomar used Ask the Experts™
on
Hi,

I am trying to update some text files from a folder that this script is in to another PC in the same network. I have checked username and password, but the script does not work. On the destination PC side, windows firewall is disabled.


net use * /DELETE

net use \\10.14.70.10\c$\backup 1 /USER:Administrator

copy /V /Y export_to_agv \\10.14.70.10\c$\backup\export_to_agv

net use \\10.14.70.10\c$\backup /DELETE
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
Only provide the share name in net use, no subfolders:
net use \\10.14.70.10\c$ 1 /USER:Administrator
...
net use \\10.14.70.10\c$ /DELETE

Open in new window

net use * /DELETE

net use T: \\10.14.70.10\c$ /USER:Administrator

copy /V /Y export_to_agv T:\backup\export_to_agv

net use T: /DELETE

Open in new window

Gerwin Jansen, EE MVETopic Advisor
Most Valuable Expert 2016
Commented:
>> net use * /DELETE
Why do you do this?  You are disconnecting all mapped drives, when files are open, your script will pause because you get a question (Y/N).

About this:

>> net use \\10.14.70.10\c$\backup 1 /USER:Administrator
What is the 1 for? I would remove it.

I would reserve 1 drive letter for your actions, like this:
net use v: /DELETE /YES
net use v: \\10.14.70.10\c$ /USER:Administrator
copy /V /Y export_to_agv\*.* v:\backup\export_to_agv
net use v: /DELETE /YES

Open in new window

Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
gerwinjansen,

The net use * /del might be necessary in cases where there is already a network connection mapped to that PC, which would lead to the following net use to fail, and the copy running with the privileges of the prior connection. But the prompt should be suppressed with /yes switch, as you have shown.

There is no use for the drive letter. It doesn't improve anything. The Network Redirector can handle the UNC fine.

The 1 is the password.
Topic Advisor
Most Valuable Expert 2016
Commented:
@Qlemo - I assumed the 1 was a typo instead of a password ;) I know the drive letter is not necessary but using a fixed (preferred) letter for this action would be my preference. However, without drive letter should work just fine as you say, presuming no other mapped drives exist when the net use /delete /yes command is given.

Author

Commented:
Thank you

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial