Solved

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

Posted on 2006-11-28
5
400 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

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

#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
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…

930 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