Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to perform a network copy of files via a batch script. However, as usual there are some networks where the 'copy' command fails saying 'Bad username or password'.

And when I try using xcopy, it never works.

I have also tried using,

net use \\server\ password /user:domain\username
net use \\server\ipc$ /user:domain\username password

But none of these work. Any ideas on how I can accomplish this? I was also wondering if it is possible to prompt the ususal Windows login dialog for this...(just an idea)

Any leads on this would be highly appreciated.
Thanks & Regards,
inteladu

share|improve this question
    
I think you don't have to put a username in, it should prompt for that. and you want a drive letter like Z: after use, and you can't just specify the name of the server you need to specify the name of the share too, and no need to end it with the trailing (like you did \\server) So net use Z: \\server\folder –  barlop May 2 '11 at 17:08
add comment

1 Answer

According to net help use, giving a password * will ask for the password on the console prompt.

For net use, you will also need to specify a device name (which can also be *, in which case the system uses the next available name), so you could try (untested)

net use * \\server\share * /user:domain\username

This should attempt to login to \\server\share with domain\username, and ask for a password on the console. After that, this share is available via some disk name, but should also be available using the UNC path (as it's successfully logged on)

share|improve this answer
    
You cannot use the UNC name from a batch file, though (unless with pushd). –  Joey May 2 '11 at 15:04
    
dir \\server\share works for me. pushd seems to work around a general limitation of the command line (being unable to enter a UNC path directly), batch file or not. –  Patrick Georgi May 2 '11 at 15:32
    
Ah, then it's just that the current directory cannot be an UNC path. Sorry. –  Joey May 2 '11 at 15:35
1  
yeah can't CD to a UNC.. an article about it here blogs.msdn.com/b/oldnewthing/archive/2007/02/15/1683851.aspx –  barlop May 11 '11 at 2:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.