Re: Trouble mapping drive to \MyOU\MyUsername Please Help
- From: "Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 12 Dec 2006 14:00:04 -0600
Kelvin wrote:
I want to map a drive to
\\<servername>\<ShareName>\TimeSheets\MyOU\MyUsername
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
If (LCase(objUser.Parent) = "ou=sales,dc=mydomain,dc=com") Then
' User object is in ou=Sales.
objNetwork.MapNetworkDrive "K:", \\MyServer\MyShare
End If
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I've tried these, but neither seem to work...
objNetwork.MapNetworkDrive "K:",
\\<servername>\<ShareName>\TimeSheets\MyOU\MyUsername
objNetwork.MapNetworkDrive "K:",
"\\<servername>\<ShareName>\TimeSheets\IT\" & wshNetwork.UserName
Depends on the client OS. On Windows 2000 or above, you can map a drive to a
subfolder of a share. On Win9x and NT it maps to the root of the share, no
matter what path you specify. One option is to share the folder you actually
want to map. For example, see this kb article:
http://support.microsoft.com/kb/168918
Note that the same restriction applies if you use the "net use" command at a
command prompt on Win9x clients to map a drive. I have seen it suggested
that you can use the subst command in a batch program to create a mapping
between a drive letter and a folder other than the root folder of a share.
This could also be done in a VBScript program. For example, something
similar to:
===========
strDrive = "M:"
strPath = "\\Server\Share\Folder\SubFolder"
Set objShell = CreateObject("Wscript.Shell")
strCmd = "%comspec% /c subst " & strDrive & " " & strPath)
objShell.Run(strCmd)
===========
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
.
- References:
- Trouble mapping drive to \MyOU\MyUsername Please Help
- From: Kelvin Beaton
- Trouble mapping drive to \MyOU\MyUsername Please Help
- Prev by Date: VBS: Finding if user explicitly logs on with cached credentials
- Next by Date: Re: checking for a group membership
- Previous by thread: Trouble mapping drive to \MyOU\MyUsername Please Help
- Next by thread: script for mapped drives
- Index(es):