Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 945
  • Last Modified:

Map network drive VBScript

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
evbuk
Asked:
evbuk
1 Solution
 
Alan_WhiteCommented:
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
 
RobSampsonCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now