Solved

Map a network drive and assign a drive letter with a batch file

Posted on 2006-11-28
5
399 Views
Last Modified: 2010-04-10
Hi

I have a program that needs a mapped drive to exist.  I have a batch file that runs each time the user logs in.  I would like to add a line that add a batch file that creates a mapped drive with a drive letter and path to my files.
I already have one in the user profile of Active directory so I need another one as a batch file.  How do you do that?

Mike
0
Comment
Question by:MickaelE
  • 2
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
ryandale56 earned 500 total points
ID: 18032555
net use Z: \\server\share

(where Z: is whatever drive letter you want)
0
 
LVL 7

Expert Comment

by:dlangr
ID: 18032560
in the batchfile add:

net use delete g:
net use g: \\server\share

You can use any letter you like, not just g, as log as it is still free.

type: net use /?   from the command line for help
0
 
LVL 7

Expert Comment

by:dlangr
ID: 18032564
log = long
0
 
LVL 6

Expert Comment

by:ryandale56
ID: 18032618
if you are going to add the "net use /delete g:"  it is /delete no just delete....notice the leading slash.
0
 

Expert Comment

by:vk3jed
ID: 18033650
I always find the method below is the most reliable

net use X: \\server\share /yes /persist:no

What this does is maps X: to \\server\share.  /yes means answer "yes" to any prompts, without stopping for user input, and /persist:no means that the share won't be persistent (remapped) at next login.  This can help with unexpected issues (e.g. if the bat file lives on a server or the server hosting the share is down at the time, it won't be mapped.  Therefore, the absence of X: can be an sign there is a problem, and you won't have Windows being bogged down by trying to access a nonexistent network drive.

Before running the batch file for the first time, make sure that the drive letter to be used is not mapped (X: in the example above).
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Fiber Patch Panel 6 42
nmap scanner? 7 78
Extending  a subnet 9 36
EIGRP on point-to-point vlan 14 21
I was recently sitting at a desk at work with one of my colleagues and needed some information on my home computer. He watched as I turned on my home computer, established a remote session into it, got the information I needed and then shut it down …
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
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…
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…

705 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

18 Experts available now in Live!

Get 1:1 Help Now