Bonjour,

Je souhaiterais créer un script VBS qui m'installe automatiquement une imprimante réseau sur un poste client en fonction de la SOUS O.U ordinateur.

Actuellement j'ai des script DOS pour l'installation des imprimante en fonction des sous o.u ordinateur.

Dans un premier temps je lance 1er script vbs qui va lancer un .cmd en fonction du nom de l'OU de l'ordinateur concerné.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
'********** Identification du poste, recherche de sa sous-OU dans l'AD et exécution du fichier
'd'imprimantes correspondant **********
 
On Error Resume Next
 
' Récupération du nom du poste
Set WshNetwork = WScript.CreateObject("WScript.Network")
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=XXX,dc=domXXX,dc=XXXX,dc=ad' 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)
 
'Exécution du fichier d'imprimantes correspondant au poste en fonction de sa sous-OU
Set wshell=CreateObject("WScript.Shell")
wshell.Run"%logonserver%\NETLOGON\Imprimantes\" & NomSou & ".cmd"
J'ai essayé de lancer le .cmd à la fin de mon nouveau VBS mais ça n'a pas marché. C'est pour cela que je veux migrer tout mes fichiers DOS en VBS.

Merci d'avance pour votre aide.