Solved

Map network drive VBScript

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

615 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