Сначала он удаляет все существующие сетевые диски. Потом подключает заданные.
On error resume next
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives
For i = 0 to oDrives.Count - 1 Step 2
WshNetwork.RemoveNetworkDrive oDrives.Item(i),true
Next
Set WshNetwork = CreateObject("WScript.Network")
Set objShell = CreateObject("Shell.Application")
On Error Resume Next
strUser = WshNetwork.UserName
strDomain = "domain.local"
Set colGroups = GetObject("WinNT://" & strDomain & "")
colGroups.Filter = Array("group")
For Each objGroup In colGroups
For Each objUser in objGroup.Members
If objUser.Name = strUser Then
Select Case objGroup.Name
Case "Пользователи домена"
wshNetwork.RemoveNetworkDrive "W:"
wshNetwork.MapNetworkDrive "W:", "\\server\share"
objShell.NameSpace("W:").Self.Name = "SERVER"
wshNetwork.RemoveNetworkDrive "X:"
wshNetwork.MapNetworkDrive "X:", "\\server\share2"
objShell.NameSpace("X:").Self.Name = "SERVER share 2"
End Select
End If
Next
Next
или через gpp
0 коммент.:
Отправить комментарий