Solved

Map network drive VBScript

Posted on 2008-10-28
2
937 Views
Last Modified: 2012-05-05
Is it possilble to write a VBScript that:

maps a netowrk drive on a local computer from Windows Server 2003

does not provide a username and password to the drive so that the user is queried for username and password by Windows when they first try to access the drive in My Computer?

I want to provide a mapped network drive for each user to a remote share on a server outside our network.  Each user has a unique username and password on that server which dictates what they can see and do on the share BUT I don't want to provide the usernames and passwords in the login script.  I want to map the drive and for the user to provide their credentials when they try to access it.

Any help appreciated.
0
Comment
Question by:evbuk
2 Comments
 
LVL 10

Expert Comment

by:Alan_White
ID: 22825616
Short answer, No.
A drive is either mapped or it isn't.  You cannot make a tentative mapping that then prompts for authentication.
You could just provide a shortcut to a script that accepts user input and maps the drive, but that doesn't sound like what you are after.
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 22825812
You could try something like this.....

Regards,

Rob.
Set objShell = CreateObject("WScript.Shell")

arrShares = Array( _

	"G:|\\server\share1", _

	"H:|\\server\share2", _

	"I:|\\server\share3" _

	)

For Each strShare In arrShares

	strDrive = Split(strShare, "|")(0)

	strPath = Split(strShare, "|")(1)

	strUserName = InputBox("Please enter a username to access " & strPath & ":", "Username")

	If Trim(strUserName) <> "" Then

		strCommand = "cmd /c net use " & strDrive & " " & strPath & " /USER:" & strUserName

		objShell.Run strCommand, 1, True

	End If

Next

Open in new window

0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

11 Experts available now in Live!

Get 1:1 Help Now