Bonjour,

Je suis complètement débutant en VBS et pour mon stage je doit créer des script qui installe des imprimantes sur un poste via le réseau. J'ai un script pour chaque imprimante. Voici ce que cela représente, pour exemple l'imprimante nommé FT01:

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
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
56
57
58
'##################################'
'# Script installation imprimante##'
'##################################'
 
	'##################################'
	'#           Variable            ##'
	'##################################'
 
		printer="FT01"
		server="TASSAV3"	
 
 
On Error Resume Next 
 
	Function Defaultprinter(printerdefault)
		Dim net
		Printerdefault="\\" & server & "\" & printer
		Set net = CreateObject("WScript.Network")
		net.SetDefaultPrinter Printerdefault
	End Function
 
 
 
 
'##################################'
'# Script désinstall imprimante  ##'
'##################################'
 
 
	Set WshNetwork = WScript.CreateObject("WScript.Network")
	PrinterPath = "\\" & server & "\" & printer
	WshNetwork.RemovePrinterConnection PrinterPath, true, true
 
 
 
'##################################'
'# Script install imprimante     ##'
'##################################'
 
	Set WshNetwork = CreateObject("WScript.Network")
	WshNetwork.AddWindowsPrinterConnection "\\" & server & "\" & printer
	WshNetwork.SetPrinter "\\wscript.arguments(0)\wscript.arguments(1)"
 
	MsgBox "IMPRIMANTE " & printer & " INSTALLEE"
 
'##################################'
'# imprimante par defaut         ##'
'##################################'
 
	Dim reponse
	reponse = MsgBox ("Voulez vous que l'imprimante" & printer & "soit l'imprimante par défaut ?", vbQuestion+vbYesNo, "Une question....")
 
	If reponse = vbYes Then 'Si reponse = oui
		call Defaultprinter(printerdefault)
		MsgBox "L'imprimante " & printer & " est par defaut", vbOk, "Information"
	Else ' Ou sinon (VbNo)
		MsgBox "L'imprimante n'est pas par defaut", vbInformation
	End If
Voyez-vous ce qui cloche ? Merci de votre compréhension