Solved

map drive in batch file

Posted on 2004-08-24
8
1,527 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
ID: 11888930
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
ID: 11889067
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
ID: 11889155
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
ID: 11897334
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
ID: 12053973
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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 …
Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

825 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