Link to home
Start Free TrialLog in
Avatar of pdurbha
pdurbha

asked on

Passing username and password as arguments in a DOS copy command

Hi,

I am trying to copy a file on to a remote server using the DOS Copy command as below...but it errors out
with a logon failure message.
C:\>copy Centricity_Extract_EPI_1.txt \\gbi-test\temp
Logon failure: unknown user name or bad password.
        0 file(s) copied.

I have two questions:
1. How can I pass the username and password as arguments in the Copy command?  
2. Can I embed the command in a .bat file and execute it as part of my build script.?

Thanks!
Avatar of contactkarthi
contactkarthi
Flag of United States of America image

ASKER CERTIFIED SOLUTION
Avatar of contactkarthi
contactkarthi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdurbha
pdurbha

ASKER

I am able to map the shared folder on the remote server by running the command

C:\>NET USE X: \\gbi-test\temp /USER:GEMEDAMERICA\Administrator Gbi123Test123
The command completed successfully.

but when I try to copy the file over into X: it says access is denied.

C:\>copy Centricity_Extract_EPI_1.txt X:
Access is denied.
        0 file(s) copied.

What am I doing wrong here?

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdurbha

ASKER

Great..it works fine..

My other problem is I  need to create a batch file .. I have tried to embed these two commands in a bat file as below: I am not sure if this is the right way of creating a bat file ..Any thoughts?

Thanks

@echo off
echo Mapping drive on remote server to local drive on build machine...
dir C:\>NET USE X: \\gbi-test\temp /USER:GEMEDAMERICA\Administrator Gbi123Test123
echo Mapping completed...
echo copying file into temp..
dir C:\>copy Centricity_Extract_EPI_1.txt X:
echo copying completed...

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

@echo off
echo Mapping drive on remote server to local drive on build machine...
NET USE X: \\gbi-test\temp /USER:GEMEDAMERICA\Administrator Gbi123Test123
echo Mapping completed...
echo copying file into temp..
copy Centricity_Extract_EPI_1.txt X:
net use X: \\gbi-test\temp  /DELETE
echo copying completed...

as shmoid told no need for a dir C: nad you can remove the share after you have copied by using net use X: \\gbi-test\temp  /DELETE

let me know if you have any trouble
Avatar of pdurbha

ASKER

ok..here's what i did:

In my batch file, I have  this:

I get the following error message, when I double-click the batch file

Mapping drive on remote server to local drive on build machine...
'C:\' is not recognized as an internal or external command,
operable program or batch file.
Mapping completed...
copying file into temp..
'C:\' is not recognized as an internal or external command,
operable program or batch file.
copying completed...
Press any key to continue . . .

When I run the  command:

C:\>NET USE X: \\gbi-test\temp /DELETE
A command was used with conflicting switches.

More help is available by typing NET HELPMSG 3510.


C:\>NET HELPMSG 3510

A command was used with conflicting switches.

What should I do next?..Please advise as I haven't worked with batch files before.

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdurbha

ASKER

Actually, I got the bat file to work..so that issue is resolved.

so, the only issue is this:

C:\>NET USE X: \\gbi-test\temp /DELETE
A command was used with conflicting switches.

More help is available by typing NET HELPMSG 3510.

I will post the points right after this..

Thanks

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdurbha

ASKER

Thanks guys u were great!

I am trying to copy a whole directory (instead of one file) using the DOS copy command to X: but it won't do it..

I have looked into xcopy also but that didn't work..any final thoughts?

Thanks
glad it worked

i think the xcopy command needs a /s

something like

xcopy *.*/s x:
Avatar of pdurbha

ASKER

I wanted to split the points between u guys..but i fouled up..sorry about that
no problem...

 if you want to split you can always get help from the moderators
there is a button that says request attention in the question.. click it and ask for help there