Solved

map drive in batch file

Posted on 2004-08-24
8
1,529 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Network bottleneck identifier 13 70
Setting out for Cisco UCS 2 61
Mapping a folder on a NAS to a drive letter 2 44
Datacenter Upgrade - Design Question 5 15
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 …
If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
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…

740 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