Solved

map drive in batch file

Posted on 2004-08-24
8
1,524 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

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Question has a verified solution.

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

Suggested Solutions

For many of us, the  holiday season kindles the natural urge to give back to our friends, family members and communities. While it's easy for friends to notice the impact of such deeds, understanding the contributions of businesses and enterprises i…
I had an issue with InstallShield not being able to use Computer Browser service on Windows Server 2012. Here is the solution I found.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

910 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

20 Experts available now in Live!

Get 1:1 Help Now