Re: mapped network drive does not show name

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 01/12/05


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


Relevant Pages

  • Login Script to Install Printers Based on Computer Group
    ... computer based on what group the computer account was in. ... originally had the printers installed via a login script when the user ... Dim objNetwork, objSysInfo, strUserDN ... Call LoadGroups(objPriObject, objGroup) ...
    (microsoft.public.win2000.active_directory)
  • LOGIN SCRIPT
    ... Here is my script: ... Dim objNetwork, objSysInfo, strUserDN ... Set objSysInfo = CreateObject ... Call LoadGroups(objPriObject, objGroup) ...
    (microsoft.public.scripting.vbscript)
  • Re: Login Script Causing Software to Install
    ... of the script as the logon script. ... You might have to wait a moment on each msgbox to see if the install starts. ... > Dim objNetwork, objSysInfo, strUserDN ... > Call LoadGroups(objPriObject, objGroup) ...
    (microsoft.public.scripting.wsh)
  • RE: export user accounts from NT 4.0 domain
    ... ATTENTION THE SCRIPT MUST BE RUNNED FROM A COMPUTER WHERE EXCEL IS ... from the information in a Microsoft Excel spreadsheet. ... Dim strLast, strFirst, strMiddle, strPW, intRow, intCol ... On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)
  • Re: Password Expire
    ... We have one fron end Edge server in our DMZ which passes email onto two ... I used to schedule a script to run every 24 hours on my Exchange 2003 ... Dim fso, txtarray, BodyText ... Call ProcessFolder (objContainer, numDays) ...
    (microsoft.public.exchange.admin)