Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBScript to Map network drive

Posted on 2006-10-31
10
Medium Priority
?
6,623 Views
Last Modified: 2011-08-18
Hi all,

Can someone help me with a VBScript to map a network drive based on Domain account ,on machine ,on group of DL .
thanks a lot in advance.
0
Comment
Question by:Jyotikadian
[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
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 17

Accepted Solution

by:
CSecurity earned 900 total points
ID: 17848492
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set AllDrives = WshNetwork.EnumNetworkDrives()

DriveLetter = "N:" 'must be capitalized
RemotePath = "\\dave\c"

AlreadyConnected = False
For i = 0 To AllDrives.Count - 1 Step 2
If AllDrives.Item(i) = DriveLetter Then AlreadyConnected = True
Next

If AlreadyConnected = False then
WShNetwork.MapNetworkDrive DriveLetter, RemotePath
WshShell.PopUp "Drive " & DriveLetter & " connected successfully."

Else
WShNetwork.RemoveNetworkDrive DriveLetter
WshShell.PopUp "Drive " & DriveLetter & " disconnected."
End if
0
 
LVL 17

Expert Comment

by:CSecurity
ID: 17848494
This code adds a network drive to address of RemotePath. If the address already exists, removes that... ;)
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17848923
or you can use WNetAddConnection API function

http://vb-helper.com/howto_map_network_drive.html
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17848928
0
 
LVL 17

Expert Comment

by:CSecurity
ID: 17849696
shijusn, they are both for VB6... Jyotikadian asks for VBscript code.
0
 
LVL 1

Author Comment

by:Jyotikadian
ID: 17855577
Hi CSecurity,

Though your script works but it does not specify the Domain account or Domain Distribution list. Can you please help me a bit more?
0
 
LVL 17

Expert Comment

by:CSecurity
ID: 17856132
What you want to do with domain account? You just going to map a network drive and network drive have a path.

You can specify the path in my code and then map it.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 17857363
may be not domain administrator has capable to see the drive

8->
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 17857372
may be just shell with net use?
0
 
LVL 17

Expert Comment

by:CSecurity
ID: 17860075
You can use net use command like:

net use w: \\monolith\pc_dist boviks_password /user:SCS\bovik
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

636 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