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
| 'Force la déclaration des variables
Option Explicit
'Indique à VBScript de passer à la ligne suivante en cas d'erreur
On Error Resume Next
' Déclaration des variables
Dim groupe, util, res, chemin, dico, strmap, fso
'Attribution d'une référence d'un objet à une variable
Set res = CreateObject("Wscript.network")
Set fso = CreateObject("Scripting.FileSystemObject")
Function IsMember(sGroup)
Dim sAdsPath,oUser,oGroup,g_oGroupDict,g_oNet
If IsEmpty(g_oGroupDict) Then
Set g_oGroupDict=CreateObject("Scripting.Dictionary")
sAdsPath = res.UserDomain &"/"& res.UserName
g_oGroupDict.CompareMode = vbTextCompare
Set oUser = GetObject("WinNT://"& sAdsPath & ",user")
For Each oGroup In oUser.Groups
g_oGroupDict.Add oGroup.Name, "-"
Next
Set oUser = Nothing
End If
IsMember = CBool(g_oGroupDict.Exists(sGroup))
End Function
'*********
'MAPPAGES
'*********
If IsMember("GRPG-partage1") then
If (fso.folderexists("K:\") = False) Then
res.MapNetworkDrive "K:", "\\mon_serveur\partage1"
Else
res.RemoveNetworkDrive "K:"
res.MapNetworkDrive "K:", "\\mon_serveur\partage1"
End If
End if
If IsMember("GRPG-partage2") then
If (fso.folderexists("K:\") = False) Then
res.MapNetworkDrive "K:", "\\mon_serveur\partage2"
Else
res.RemoveNetworkDrive "K:"
res.MapNetworkDrive "K:", "\\mon_serveur\partage2"
End If
End if
wscript.quit |
Partager