I have a logon script that maps network drives based on group membership. I
have a personal drive P that is maped using ADUC. After the user has logon
once, the drives maps fine. When they go to logon again I am getting an
error...

The local device name is already in use.
80070055
WSHNetwork.MapNetworkDrive

I have tried an logoff script...

Dim wshNetwork
Set wshNetwork = CreateObject("WScipt.Network")
Set Drives = wshNetwork.EnumNetworkDrives
If Drives.count = 0 then
Else
for x = 0 to Drives.count-1 Step 2
wshNetwork.RemoveNetworkDrive Drives.Item(x),bForce, BUpdateProfile
Next
End If

This works ok, but sometimes I get an error when syn with folder redirect.

So what I want to do is in the logon script, remove all drives before
remaping. However since I am mapping the P drive using ADUC it is removed.
Is There a way to modify the code to not remove the P drive when I place this
in the beginning of the logon script.

TIA

RE: Enumerate Network Drives by RemS

RemS
Mon Sep 10 13:36:02 PDT 2007

"John" wrote:
> I have a logon script that maps network drives based on group membership. I
> have a personal drive P that is maped using ADUC. After the user has logon
> once, the drives maps fine. When they go to logon again I am getting an
> error...
>
> The local device name is already in use.
> 80070055
> WSHNetwork.MapNetworkDrive
>
> I have tried an logoff script...
>
> Dim wshNetwork
> Set wshNetwork = CreateObject("WScipt.Network")
> Set Drives = wshNetwork.EnumNetworkDrives
> If Drives.count = 0 then
> Else
> for x = 0 to Drives.count-1 Step 2
> wshNetwork.RemoveNetworkDrive Drives.Item(x),bForce, BUpdateProfile
> Next
> End If
>
> This works ok, but sometimes I get an error when syn with folder redirect.
>
> So what I want to do is in the logon script, remove all drives before
> remaping. However since I am mapping the P drive using ADUC it is removed.
> Is There a way to modify the code to not remove the P drive when I place this
> in the beginning of the logon script.

Dim wshNetwork
Set wshNetwork = CreateObject("WScipt.Network")
Set Drives = wshNetwork.EnumNetworkDrives
If CBool(Drives.count) then
for x = 0 to Drives.count-1 Step 2
If not oDrives.Item(x) = "P:" Then _
wshNetwork.RemoveNetworkDrive Drives.Item(x), True, True
Next
End If

wshNetwork.MapNetworkDrive strLocalDrive1, strRemoteShare1, False
wshNetwork.MapNetworkDrive strLocalDrive2, strRemoteShare2, False
wshNetwork.MapNetworkDrive strLocalDrive3, strRemoteShare3, False
wshNetwork.MapNetworkDrive strLocalDrive4, strRemoteShare4, False

(where persistent mapping is forced to False)


\Rems