1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| Dim WshNetwork, WshShell
Set objNetwork = CreateObject("WScript.Network")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
fUser = WshNetwork.UserName
fDomain = WshNetwork.UserDomain
Function IsMember(sGroup)
Dim sAdsPath, oUser, oGroup
If IsEmpty(oGroupDict) Then
Set oGroupDict = CreateObject("Scripting.Dictionary")
oGroupDict.CompareMode = vbTextCompare
sAdsPath = WshNetwork.UserDomain & "/" & WshNetwork.UserName
Set oUser = GetObject("WinNT://" & sAdsPath & ",user")
For Each oGroup In oUser.Groups
oGroupDict.Add oGroup.Name, "-"
Next
Set oUser = Nothing
End If
IsMember = CBool(oGroupDict.Exists(sGroup))
if (IsMember) then
'User is a member of the group specified.
end if
End Function
if isMember("profs") then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("Wscript.Network")
If (objFSO.DriveExists("W:") = True) Then
objNetwork.RemoveNetworkDrive "W:", True, True
WScript.sleep 5
end if
wshNetwork.MapNetworkDrive "W:", "\\IP\profs"
msgBox ("blabla")
If (objFSO.DriveExists("Z:") = True) Then
objNetwork.RemoveNetworkDrive "Z:", True, True
WScript.sleep 5
end if
wshNetwork.MapNetworkDrive "Z:", "\\IP\classes"
Else if isMember("classes") then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("Wscript.Network")
If (objFSO.DriveExists("Z:") = True) Then
objNetwork.RemoveNetworkDrive "Z:", True, True
WScript.sleep 5
end if
wshNetwork.MapNetworkDrive "Z:", "\\IP\classes"
msgBox ("blabla")
Else
msgBox ("blabla")
End If
End if |
Partager