Solved

Map network drive VBScript

Posted on 2008-10-28
2
934 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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