C'est sur un reseau AD (Active Directory) ??
Si c est le cas, voila mon script qui peut lui aussi t etre utile ;)
'*******Determin Active Directory Account Information by binding to the user object in AD***********
' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_DOMAIN = 1
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1179 = 1
Dim Filesystem
Dim InPutFile
Dim arrname
Dim clPrinters
Dim strPrinterName
Dim printer_file
Dim network_share_file
Dim strNetworkShare
Dim strDriveLetter
Dim clshares
'Dim objRootDSE
On Error Resume Next
Set objNetwork = CreateObject("Wscript.Network")
'Retrieve Computer Name
strComputerName = objNetwork.ComputerName
' Retrieve user NT logon name.
strNTName = objNetwork.UserName
' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
' Use the NameTranslate object to find the NetBIOS domain name from the
' DNS domain name.
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_TYPE_NT4, strDNSDomain
objTrans.Set ADS_NAME_TYPE_1179, strDNSDomain
strNetBIOSDomain = objTrans.Get(ADS_NAME_TYPE_NT4)
' Remove trailing backslash.
strNetBIOSDomain = Left(strNetBIOSDomain, Len(strNetBIOSDomain) - 1)
' Use the NameTranslate object to convert the NT user name to the
' Distinguished Name required for the LDAP provider.
objTrans.Init ADS_NAME_INITTYPE_DOMAIN, strNetBIOSDomain
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strNTName
strUserDN = objTrans.Get(ADS_NAME_TYPE_1179)
' Bind to the user object in Active Directory with the LDAP provider.
Set objUser = GetObject("LDAP://" & strUserDN)
'msgbox "strUserDN = " & strUserDN
'msgbox "objUserName = " & objUserName
'msgbox "objUser.distinguishedName = " & objUser.distinguishedName
'msgbox "objUser.Country=" & objUser.countryCode
' Display various names.
'************** Find current time and date and display login prompt****************************
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LocalTime")
For Each objItem in colItems
intMonth = objItem.Month
intDay = objItem.Day
intYear = objItem.Year
dtmDate = intMonth & "/" & intDay & "/" & intYear
intHour = objItem.Hour
dim Txt1(2),Txt2(2),Txt3(2),Txt4(2),Txt5(2),Txt6(2),Txt7(2),Txt8(2),Txt9(2)
If intHour < 12 Then
Txt1(0) = "Good morning"
Txt1(1) = "Bonjour"
ElseIf intHour => 12 And intHour < 18 Then
Txt1(0) = "Good afternoon"
Txt1(1) = "Bon aprs-midi"
ElseIf intHour > 18 Then
Txt1(0) = "Good evening"
Txt1(1) = "Bonsoir"
End If
intMinutes = objItem.Minute
If intMinutes < 10 Then
intMinutes = "0" & intMinutes
End If
intSeconds = objItem.Second
If intSeconds < 10 Then
intSeconds = "0" & intSeconds
End If
dtmTime = intHour & ":" & intMinutes & ":" & intSeconds
Next
'Langue de l utilisateur
indice=0
if objUser.countryCode = 250 then
indice=1
end if
'Texte afficher
Txt2(0) = " and welcome to the GIAT-EAU Network."
Txt2(1) = " et bienvenue sur le rseau GIAT-EAU."
Txt3(0) = "You are logging into computer "
Txt3(1) = "Vous tes logu sur l'ordinateur "
Txt4(0) = "The current date and time is: "
Txt4(1) = "La date et l'heure actuelle sont : "
Txt5(0) = "Please note that all system usage is monitored and that by clicking OK below, you"
Txt5(1) = "Veuillez noter que toute utilisation du systme est control et qu'en cliquant OK ci-dessous"
Txt6(0) = "confirm that you understand & accept this as part of the GIAT-EAU IT User Policy."
Txt6(1) = "vous confirmez que vous comprennez et acceptez entirement la charte utilisateur GIAT-EAU."
Txt7(0) = "Please note that this policy is subject to periodic update and you are advised"
Txt7(1) = "Veuillez noter que cette charte peut tre assujetie des changements et que vous devez"
Txt8(0) = "to refresh yourselves with the contents of the policy on a regular basis."
Txt8(1) = "vous mme vous informer de son contenu rgulirement."
Txt9(0) = "A copy of the IT User Policy can be found in:"
Txt9(1) = "Une copie de cette charte est disponible sur :"
'Envoie du message
MsgBox (Txt1(indice) & " " & objUser.givenName & " " _
& objUser.sn & Txt2(indice) _
& vbCRLF _
& vbCRLF & Txt3(indice) & strNetBIOSDomain _
& "\" & strComputerName & "." & vbCRLF _
& vbCRLF & Txt4(indice) & dtmDate & " " & dtmTime _
& vbCRLF & vbCRLF _
& Txt5(indice) _
& vbCRLF & Txt6(indice) _
& vbCRLF & Txt7(indice) _
& vbCRLF & Txt8(indice) _
& vbCRLF _
& vbCRLF & Txt9(indice) _
& vbCRLF & "U:\ disposition\Procdures informatique\EAU Exigences de scurit.doc")
'Suppression des anciens lecteurs
objNetwork.RemoveNetworkDrive "Q:", True, True
objNetwork.RemoveNetworkDrive "R:", True, True
objNetwork.RemoveNetworkDrive "S:", True, True
objNetwork.RemoveNetworkDrive "T:", True, True
objNetwork.RemoveNetworkDrive "U:", True, True
objNetwork.RemoveNetworkDrive "V:", True, True
'Ajout des lecteurs communs
objNetwork.MapNetworkDrive "Q:", "\\srv\Applications"
objNetwork.MapNetworkDrive "S:", "\\srv\Scanner"
objNetwork.MapNetworkDrive "U:", "\\srv\users"
objNetwork.MapNetworkDrive "V:", "\\srv\userb"
'Ajout des imprimantes communes
objNetwork.AddWindowsPrinterConnection "\\srv\ImpHermes"
objNetwork.AddWindowsPrinterConnection "\\srv\Kyocera"
objNetwork.AddWindowsPrinterConnection "\\PcImprimante\HP_A3_Couleur"
'Ajouts des imprimantes et lecteurs spcifiques
arrMembersOf = objUser.GetEx("memberOf")
For Each strMemberOf in arrMembersOf
LGrp = LCase(right(strMemberOf,len(strMemberOf) -3))
LGrp = left(LGrp,InStr(LGrp,",cn") -1 )
Select case (LGrp)
Case "rav":
objNetwork.AddWindowsPrinterConnection "\\srv\ImpRav"
Case "flux":
objNetwork.AddWindowsPrinterConnection "\\srv\ImpFlux"
Case "dg":
objNetwork.AddWindowsPrinterConnection "\\srv\ImpDG"
Case "rh":
objNetwork.AddWindowsPrinterConnection "\\srv\ImpRH"
objNetwork.AddWindowsPrinterConnection "\\srv\ImpTahsin"
Case "btq":
objNetwork.AddWindowsPrinterConnection "\\srv\ImpBTQ"
Case "contrat eau":
objNetwork.MapNetworkDrive "R:", "\\srv\Ressource"
Case "compta":
objNetwork.MapNetworkDrive "T:", "\\Srvsage\soc001"
objNetwork.AddWindowsPrinterConnection "\\srv\ImpCompta"
Case "admins du domaine":
objNetwork.AddWindowsPrinterConnection "\\srv\ImpBTQ"
objNetwork.AddWindowsPrinterConnection "\\srv\ImpRH"
objNetwork.AddWindowsPrinterConnection "\\srv\ImpDG"
objNetwork.AddWindowsPrinterConnection "\\srv\ImpFlux"
objNetwork.AddWindowsPrinterConnection "\\srv\ImpRav"
objNetwork.MapNetworkDrive "R:", "\\srv\Ressource"
objNetwork.MapNetworkDrive "T:", "\\Srvsage\soc001"
end select
Next
'Vrification Outlook
set fs = CreateObject("Scripting.FileSystemObject")
nRep = "d:\donnees\outlook"
set MonRep = fs.GetFolder(nRep)
for each oFile in MonRep.files
if lcase(right(oFile.path,3)) = "pst" and (oFile.Size / 1024 /1024) > 1024 then
msgbox "Votre fichier outlook " & oFile.path & " est bien trop important " & round(oFile.Size / 1024 /1024) _
& " Mo." & vbCRLF & "Veuillez contacter l'administrateur de votre systme."
end if
next
set ColFiles = nothing
set MonRep = nothing
set fs = nothing
'Suppression des imprimantes de l ancien rseau
Set oPrt = objNetwork.EnumPrinterConnections
For i = 0 to oPrt.Count - 1 Step 2
If lcase(Left (oPrt.Item(i+1), 7)) = "\\srv1\" Then
objNetwork.RemovePrinterConnection oPrt.Item(i+1)
End If
next
if indice =0 then
Msgbox "Your computer is ready. Thanks."
else
Msgbox "Votre ordinateur est prt. Merci."
End if