Solved

map drive in batch file

Posted on 2004-08-24
8
1,522 Views
Last Modified: 2012-06-21
I am trying to map a drive in a batch file.  the command is...

net use y: \\server\share password /user:domain\username

it works when I do it from a command line, but when I put it in a batch file and run that I get...

System error 1326 has occured.
Logon failure: unknown user name or bad password.

I am doing this on a Windows 2003 server trying to connect to another of the same.  Any thoughts?

Thanks,
Tim
0
Comment
Question by:timnorvel
8 Comments
 
LVL 10

Expert Comment

by:dis1931
Comment Utility
I believe the problem you are running into is that when you are running this from a batch file as a different user it should prompt for credentials of the username you specify.....if you are doing this when logged in as the username that you are specifying in the net use command then it will not prompt you for credentials as they are already present due to your login...

Dis
0
 
LVL 7

Expert Comment

by:wparrott
Comment Utility
Unless the username you are logging onto the 1st server with doesn't have permissions to access the shared folder on the 2nd server, you don't have to specify the username/password in the net use command.

Try replacing the password in the batch line with an asterick '*' and log in again. It should prompt you for the password in the command prompt. Does it work this way?
0
 

Expert Comment

by:mzgola
Comment Utility
net use y: \\server\share password /user:domain\username

try to username@domain.com "use your domain name" or just do it like /user:domain\%username%

0
 

Author Comment

by:timnorvel
Comment Utility
Thanks for the comments.  I should have mentioned that I am trying to schedule this batch file to run a few times a day, so no one will be logged in at the time.  But I have the same error if I run the batch file while logged in or not.  The user I am logged in as is the one I specify in the batch file, but again, I get the error when logged in or not and it works when I type the same thing into a command line, specifying the user just like in the batch file.

I just realized, I don't know for sure that I get the "same" error when the batch file runs as a scheduled task, as I don't see the error... only the error in scheduled tasks that it did not run correctly.  I am assuming it's the same error though.

I used to do this same thing on a Windows 2000 server.  What's the difference?!
0
 
LVL 2

Accepted Solution

by:
DiCeR earned 125 total points
Comment Utility
I believe you can not do drive-mapping and network interactions in a non-interactive session.

I had a similar problem some time ago trying to schedule a copy of files to/from network-drives. It worked interactively. It didnt in a schedule. I ended up working around it with web/ftp-requests which doesent rely on NT-credentials for network-operations.

If you indeed used to do this with a W2K-Server (which I wonder how you managed) and now cannot do it with a W2K3-Server, I believe this has something to do with the access-permissions the scheduler-service runs as.

EE has earlier answered something similar. You might try this approach:
http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_21002545.html
http://www.experts-exchange.com/Programming/Q_20965343.html
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The DSL Parameters part of this article is valid and can be considered with any brand of internet router and modem (Dlink, 3com, Alcatel, Usrobotics, Parks), by accessing the configuration interface available by the manufacturer eg: http://10.1.1.1 …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now