Solved

Map network drive VBScript

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Collapse and expand table in Word 2010 2 161
Delete Disconnected Site from Active Directory 3 76
Automate Windows Updates with SCCM 2 127
vb6 Where condition on dbo 2 30
Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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