Bonjour tout le monde, J'ai un petit problème avec "Option explicit" !

J'ai trouvé un code vbs permettant d'afficher pas mal d'informations sur les disques durs d'un ordinateur, Je l'ai pris et un peu modifié. Seulement voilà : J'aimerais utiliser "Option explicit". D'après ce que j'ai compris, c'est tout une histoire de déclaration de variable. Mais quand je le fais... ça ne marche pas ! J'ai surement oublié une variable quelque part, ou quelque chose d'autre mais je ne trouve pas .. Est-ce que quelqu'un pourrait m'aider à trouver cette erreur ?

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
'Affichage des informations : Disques durs.
typeD=Array("Inconnu","Amovible","Fixe","Réseau","CD-ROM","RAM Disk")
Dim net, shell, computer, args, fso, WMISet, oWinnt
Set net   = Wscript.CreateObject("WScript.Network")
Set shell = WScript.CreateObject("WScript.Shell")
Set fso   = WScript.CreateObject("Scripting.FileSystemObject")
Set args  = Wscript.Arguments
nbargs=args.count
 
If testarg("d") Then
	domain=getarg("d")
	If domain="" Then
		Set ComputerSystem = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_ComputerSystem")
		for each ComputerItem in ComputerSystem
		    domain=ComputerItem.Domain
			next	
		End If
	Wscript.echo "Analyse des disques des ordinateurs du domaine " & Ucase(Domain)
	Wscript.echo "-----------------------------------------------" & string(len(Domain),"-") 
	set oWinnt=GetObject("WinNT://" & domain)
	For each oDomainItem in oWinnt
		classe=oDomainItem.Class
		Computer=oDomainItem.Name
		If classe="Computer" Then InfosDisques Computer 
		Next
else
	If testarg("m") then
		computer=getarg("m")
	else
		computer=net.ComputerName
		End If
	InfosDisques Computer	
	End If
'--------------------------------------------------------------------
Sub InfosDisques(computer)
set WMISet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & Computer).ExecQuery _
	("SELECT * FROM Win32_LogicalDisk")
wscript.echo "Affichage des informations sur les disques durs : "
wscript.echo "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯"
Message=VBCRLF
Message=Message & "   | " & FormatStrL("Nom",11) & " | " & FormatStrL("Type",8) 
Message=Message & " | " & FormatStrL("Système",8) 
Message=Message & " | " & FormatStrL("    Taille (Mo) ",17)
Message=Message & " | " & FormatStrL("  %",3) 
Message=Message & " | " & FormatStrL("N°série",8) 
Message=Message & VBCRLF 
Message=Message & "   | " & FormatStrL("",11) & " | " & FormatStrL("",8) 
Message=Message & " | " & FormatStrL("",8) 
Message=Message & " | " & FormatStrR("Maxi",7) & " | " & FormatStrR("Libre",7) 
Message=Message & " | " & FormatStrL("lib",3)
Message=Message & " | "
Message=Message & VBCRLF 
Message=Message & "---+-------------+----------+----------+---------+---------+-----+---------" 
Message=Message & VBCRLF 
CumulTotal=0
CumulAvail=0
Mega=1048576
For each Disk in WMISet
	Capa=Disk.Size
	Desc=TypeD(Disk.DriveType-1)
	If Capa<>"" Then
		Name=Disk.VolumeName
		Serial=Disk.VolumeSerialNumber
		TT=int(cdbl(Capa)/mega)
		TL=int(cdbl(Disk.FreeSpace)/mega)
		Syst=Disk.FileSystem
		If TT>0 Then
			pc=int(TL*100/TT)
		Else
			pc=""
			End If
		If Disk.DriveType=3 Then
			CumulTotal=CumulTotal+TT
			CumulAvail=CumulAvail+TL
			End If
	Else
		Name=""
		Serial=""
		TT=""
		TL=""
		Syst="non prêt"
		pc=""
		End If
	Message=Message & Disk.Name & " | " & FormatStrL(name,11) & " | " & FormatStrL(Desc,8)
	Message=Message & " | " & FormatStrL(syst,8)
	Message=Message & " | " & FormatStrR(TT,7) & " | " & FormatStrR(TL,7) 
	Message=Message & " | " & FormatStrR(pc,3)& " | " & Serial 
	Message=Message & VBCRLF 
	Next
Message=Message & "---+-------------+----------+----------+---------+---------+-----+---------" 
Message=Message & VBCRLF 
Message=Message & "   | " & FormatStrL("TOTAL fixes",11) & " | " & FormatStrL("",8)
Message=Message & " | " & FormatStrL("",8)
Message=Message & " | " & FormatStrR(CumulTotal,7) & " | " & FormatStrR(CumulAvail,7)
Message=Message & " | " & FormatStrR(int(CumulAvail*100/CumulTotal),3)
Message=Message & " | " & VBCRLF
wscript.echo Message
End Sub
'--------------------------------------------------------------------
Function FormatStrL(ch,lmax)	'Fonction avec l'espace APRÈS.
l=len(ch)
If l<lmax Then 
	For k = l+1 To lmax
		ch=ch & " "
		Next
	End If
FormatStrL=ch
End Function
'--------------------------------------------------------------------
Function FormatStrR(ch,lmax) 	'Fonction avec l'espace AVANT.
l=len(ch)
If l<lmax Then 
	For k = l+1 To lmax
		ch=" " & ch
		Next
	End If
FormatStrR=ch
End Function
'--------------------------------------------------------------------
Function testarg(param)
testarg=false
For i = 0 To nbargs-1
	curarg=lcase(args(i))
	If left(curarg,1)="/" or left(curarg,1)="-" Then
		If mid(curarg,2,len(param))=param Then
			testarg=true
			exit function
			End If
		End If
	Next
End Function
'--------------------------------------------------------------------
Function getarg(param)
getarg=""
For i = 0 To nbargs-1
	curarg=lcase(args(i))
	If left(curarg,1)="/" or left(curarg,1)="-" Then
		If mid(curarg,2,len(param))=param Then
			getarg=mid(args(i),2+len(param))
			exit function
			End If
		End If
	Next
End Function
'--------------------------------------------------------------------
 
'saisie pour bloquer la fermeture de la console.
WScript.StdIn.ReadLine
Après avoir fait une "Liste" des différentes variables utilisées, J'obtiens ça :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
Option Explicit
 
Dim typeD, net, shell, fso, args, nbargs, domain, ComputerSystem, ComputerItem, oWinnt, oDomainItem, classe, Computer, computer
Dim WMISet, Message, CumulTotal, CumulAvail, Mega, Capa, Desc, Name, Serial, TT, TL, Syst, pc		
Dim l, ch, lmax, k
Dim testarg, i, curarg, param, getarg
Mais lorsque j'exécute, J'ai une erreur :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
test.vbs(4,120) Erreur de compilation Microsoft VBScript : Redéfinition de nom
Je désespère !!

Merci d'avance ..