Re: Mapping drives

Tech-Archive recommends: Fix windows errors by optimizing your registry



Sorry for the delayed response... No, it won't map "T" twice (It can only be
mapped to one resource anyway). Look closer at the code.

The script enters the IF statement and first checks to see if "T" is already
in use. If so...
Next is checks to see if "T" is mapped to the correct share. In the first
case, it was correctly mapped and can exit the sub.
Else, "T" was in use, but not mapped to the correct share. So Remove "T" and
then remap it to the correct share, then exit the sub.
If "T" was not in use, then the script skips the IF statements and just maps
the drive and now you can exit the sub. Works every time!

Buddy G

"Dwight" <dwight@xxxxxxxxxxxxx> wrote in message
news:1113848308.201541.161350@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> Buddy Greenshield wrote:
> > If you're using vbscript to map the drives, first test to see if it's
> > already mapped to the correct share, if it is, continue. If it's not,
> remove
> > the mapping and remap. Use this code for each drive you need to map.
> >
> > Example:
> > Dim oNet, oDrives
> > Set oNet = WScript.CreateObject("WScript.Network")
> > Set oDrives = oNet.EnumNetworkDrives
> > For i = 0 to oDrives.Count - 1 Step 2
> > If oDrives.Item(i) = "T:" Then
> > If oDrives.Item(i+1) = "\\sbsComputer\ShareName" Then
> > Continue with your script here...all is well
> > Else
> > oNet.RemoveNetworkDrive "T:"
> > oNet.MapNetworkDrive "T:","\\sbsComputer\CorrectShareName"
> > Continue with your script...the mapping has been corrected
> > End If
> > End If
> > Next
> > oNet.MapNetworkDrive "T:","\\sbsComputer\CorrectShareName"
> > Continue with your script, It wasn't mapped, but now it is.
> >
> > Buddy G
> >
> >
> Won't this script map the T: drive twice?
>
> The MapNetworkDrive is issued twice if the maping is incorrect and once
> if it is correct.
>


.



Relevant Pages

  • Re: troubleshoot a script
    ... I see you use the memberOf attribute. ... ' map appropriate drives. ... The part of the script that will not work for the 3 ...
    (microsoft.public.scripting.vbscript)
  • Unable to remove remembered drives
    ... The script is completely finished and works perfectly if I ... It turned out that it couldn't map the drive for some ... appears I cant remove these remembered drives, ... Set fso = Createobject ...
    (microsoft.public.scripting.vbscript)
  • Drive Mapping Script Not working
    ... I have a script that maps drives based on a machines name here is a sample ... net use and map the share correctly net use reports the share to already be ...
    (microsoft.public.windows.server.scripting)
  • Re: User Independent Mapped Drive
    ... OU that runs a batch file to map the drives. ... server of where they're from. ... script, ...
    (microsoft.public.windows.server.networking)
  • Re: Issues mapping network drive via login script
    ... the scripts if they dont all connect cause they dont "understand" how to map ... The computer that is not mapping the drives - does it have any of those ... CD/DVDROMs in Disk Management so that my script could actually map the drive ... I have login scripts assigned to the domain users via the Profile ...
    (microsoft.public.windowsxp.general)