Re: mapped network drive does not show name
From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 01/12/05
- Next message: Gerry Hickman: "Re: NTFS Effective Permissions?"
- Previous message: Diego Truffer: "Re: Open IE with Script"
- In reply to: tony: "mapped network drive does not show name"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 12 Jan 2005 21:00:48 +0100
tony wrote:
> I mapped a network drive using tyhe below script
>
> when k drive is mapped. It just shows as "network drive (K:)" instead of the
> full share name
>
> q drive shows as "IT on 'server'"
>
> why is that? how cna I have the full share name next to letter drive?
Hi
I saw this issue on some computers last year (after some
security updates from Microsoft).
So on those computers, I added a script in the startup folder that
added the description back (after the logon script had mapped the
drives).
This subroutine AdjustDriveDescription added to your script:
'--------------------8<----------------------
Dim objNetwork, objSysInfo, strUserDN, objUser, strUser
Set objNetwork = CreateObject("Wscript.Network")
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.userName
strUser = objNetwork.UserName
Set objUser = GetObject("LDAP://" & strUserDN)
If IsMember("SUSE IT") Then
'objNetwork.removenetworkdrive "q:"
objNetwork.MapNetworkDrive "q:", "\\server\IT"
objNetwork.MapNetworkDrive "k:", "\\server\Users\" & strUser, false
End If
AdjustDriveDescription
'--------------------------------------------------------
Function IsMember(strGroup)
' Function to test one user for group membership.
' objUser is the user object with global scope.
' strGroup is the NT Name of the group to test.
' objGroupList is a dictionary object with global scope.
' Returns True if the user is a member of the group.
Dim objGroup
If IsEmpty(objGroupList) Then
Set objGroupList = CreateObject("Scripting.Dictionary")
objGroupList.CompareMode = vbTextCompare
For Each objGroup In objUser.Groups
objGroupList(objGroup.sAMAccountName) = True
Next
End If
IsMember = objGroupList.Exists(strGroup)
End Function
Sub AdjustDriveDescription
On Error Resume Next
Dim oShellApp, oWshNet, oDrives, i, sDrive, sDriveDesc
Dim sUNCPath, aUNCPath, sNewDriveDesc, sLastElement
Set oShellApp = CreateObject("Shell.Application")
Set oWshNet = CreateObject("WScript.Network")
Set oDrives = oWshNet.EnumNetworkDrives
For i = 0 to oDrives.Count - 1 Step 2
sDrive = oDrives.Item(i) & "\"
sDriveDesc = oShellApp.NameSpace(sDrive).Self.Name
If Len(sDriveDesc) < 7 Then
' remove the \\ in front
sUNCPath = LCase(Mid(oDrives.Item(i+1), 3))
aUNCPath = Split(sUNCPath, "\")
If UBound(aUNCPath) > 0 Then
sLastElement = aUNCPath(UBound(aUNCPath))
sNewDriveDesc = sLastElement & " on '" _
& Left(sUNCPath, Len(sUNCPath) - Len(sLastElement) - 1) & "'"
oShellApp.NameSpace(sDrive).Self.Name = sNewDriveDesc
End If
End If
Next
On Error Goto 0
End Sub
'--------------------8<----------------------
-- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter/default.mspx
- Next message: Gerry Hickman: "Re: NTFS Effective Permissions?"
- Previous message: Diego Truffer: "Re: Open IE with Script"
- In reply to: tony: "mapped network drive does not show name"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|