Solved

Map network drive VBScript

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBscript/Batch file: copy files/folders based on a csv file 15 88
VbScript to countdown to New Year's Day 6 65
Questions about DHCP migration 5 81
VBA Vbscript  Issue 9 25
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

840 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