Re: Logon Drive Mapping script

From: Will S (dontpanic1.nospam_at_hotmail.nospam.com.nospam)
Date: 01/24/05


Date: Mon, 24 Jan 2005 06:06:51 -0800

This fix seems to work pretty good...but I'm seeing inconsistent
behavior where it sometimes will not rename the display name to what
the share is currently mapped to.

Is there a limit as to the number of drive descriptions it can adjust
or some better way to use the subroutine for scripts that potentially
map multiple drives?

Thanks,
Will

Torgeir Bakken (MVP) wrote:

> Timothy Hasty wrote:
>
> > Correction *---*
> >
> > This script will remap to the correct drive.
> >
> > Here is the problem.
> >
> > Example:
> >
> > Drive y is mapped to \\dc2\h
> >
> > when I run the script it is suppose to remap the drive to \\data\f
> >
> > I run the script. In my computer it still looks like y is mapped to
> > \\dc2\h
> >
> > If I open the Y Drive it opens the correct \\data\f path.
> >
> > But it still lists in My Computer as y: H on DC2
> Hi
>
> Very strange, and I don't have a direct solution for you.
>
> But a workaround is to add the sub-routine AdjustDriveDescription
> listed below to your script, and when you are finished mapping the
> drives, make a callout to the sub like this:
>
>
> ....
>
> AdjustDriveDescription
>
> ' Clean up.
> Set objGroupList = Nothing
> Set objUser = Nothing
> Set objNetwork = Nothing
> ...
>
>
> '--------------------8<----------------------
>
> 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
>
> ' 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
> Next
> On Error Goto 0
> End Sub
>
>
> '--------------------8<----------------------



Relevant Pages

  • Loop for only 10 cycles
    ... The script below works great for mapping over a VPN and uses an .htm page to ... I'm concerned that it will get caught in a never ending loop when ... it's mapping the drives if it's unable to find the drive. ... Sub QDRIVE ...
    (microsoft.public.windows.server.scripting)
  • Re: Problem: USB drive letter auto assignment on insert
    ... As promised I made the script and posted it here for others to use. ... modify it to work under Windows 2000 please go ahead and post the mods here. ... Sub SINK_OnObjectReady ... If you want to select drives you can use: ...
    (microsoft.public.windows.server.scripting)
  • Re: Problem: USB drive letter auto assignment on insert
    ... 'only works under Windows Server 2003 ... Sub SINK_OnObjectReady ... I've been working on the static drive letter script and nearly have it ... If you want to select drives you can use: ...
    (microsoft.public.windows.server.scripting)
  • Cross Platform VBScript
    ... I've made a script to map a set of network drives and then rename them to ... Sub Map_Drives ... Sub Printers ...
    (microsoft.public.scripting.vbscript)
  • Re: Script initiate a drive connection?
    ... Network & Software Integration ... Dim objWMI, objPing, colPings, ServerOnline, Result ... in a script the double click on a disconnected drive. ... automatically connect map drives on boot up.) ...
    (microsoft.public.windows.server.scripting)

Loading