1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| ' La syntaxe à utiliser est :
' - Pour retirer le mappage : object.RemoveNetworkDrive(strName, [bForce], [bUpdateProfile])
' - Pour le mappage : object.MapNetworkDrive(strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword])
' ** Il en va de soi que les paramètres entre crochets sont facultatifs, la décision te revient
Option Explicit
Dim objNetWork, I, oDrives, strUserName, strPassWord
Set objNetWork = WScript.CreateObject("WScript.Network")
' On cherche le lecteur réseau: si mappé on le déconnecte
Set oDrives = objNetWork.EnumNetworkDrives
For I = 0 to oDrives.Count - 1 ' Step 2
If InStr(1, LCase(oDrives.Item(I)), "s:") > 0 Then
objNetWork.RemoveNetworkDrive "S:" , True, True
Exit For
End If
Next
' Une fois la déconnexion faite, on fait le mappage avec d'autres informations
objNetWork.MapNetworkDrive "S:", "\\Server\SharedFolder", True, strUserName, strPassWord |
Partager