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
|
'==============================================================================
' Gestion des imprimantes
'==============================================================================
' Récupération du nom du poste
Dim WshNetwork, objNetwork, NomPoste, objConnection, objCommand, objRecordSet, Enreg_AD, Dcoupe
Set WshNetwork = CreateObject("WScript.Network")
Set objNetwork = CreateObject("WScript.Network")
set WSHShell = CreateObject("WScript.Shell")
NomPoste = WshNetwork.ComputerName
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
'Localisation du poste dans l'AD
objCommand.CommandText = "SELECT ADsPath FROM 'LDAP://OU=domaine,dc=xxx' WHERE objectCategory='computer' AND name='" & NomPoste & "'"
Set objRecordSet = objCommand.Execute
'Récupération de la sous-OU du poste
Enreg_AD=objRecordSet.Fields("ADsPath").Value
Dcoupe=split("" & Enreg_AD & "",",")
NomSou=mid(Dcoupe(1),4)
'Suppression de toutes les imprimantes réseaux
Set Printers = WshNetwork.EnumPrinterConnections
For i = 0 to Printers.Count - 1 Step 2
If Left(ucase(Printers.Item(i+1)),2) = "\\" Then
WSHNetwork.RemovePrinterConnection Printers.Item(i+1)
End IF
Next
'===============================================================================
'COMMUN
'===============================================================================
objNetwork.AddWindowsPrinterConnection "\\serveur\PDFCreator"
'===============================================================================
'BUREAU 603
'===============================================================================
if NomSou = "BUREAU_603" then
objNetwork.AddWindowsPrinterConnection "\\serveur\xerox7545"
objNetwork.AddWindowsPrinterConnection "\\serveur\SPMX3100"
objNetwork.AddWindowsPrinterConnection "\\serveur\HP3500"
end if |
Partager