Je ne comprend pas pourquoi mon script ne s'arrête pas lorsque "intEndIP" est atteint.
Les valeurs "strSubnet", "intStartIP" et "intEndIP" sont bien pris en compte par le script.
Celui-ci début bien sur la première adresse IP saisie et correspondante à "strSubnet" + "intStartIP".
Soit dans mon script :
strComputer = strSubnet & strIP
Mais lorsqu'il arrive sur la dernière adresse IP demandée, le script continu en testant les adresses IP qui suivent sans prendre en compte :
Do Until x > intEndIP
J'ai remarqué que si je remplace
intEndIP EndIP par <gras>intEndIP 100</gras>
cela fonctionne.
Quelqu'un peut-il me dire d'où vient le problème ?
Merci par avance.
Voici mon script :
'User Input of Network ip
Message = "Please enter Network IP:" & chr(10) & chr(10) & _
"Example: For 55.7.159.0/24" & chr(10) & _
"Type '55.7.159.' whitout '0'"
Title = "Network IP"
Network = InputBox(Message, Title, "55.7.159." )
strSubnet = Network
'User Input of Start ip
Message = "Please enter Start IP Range:" & chr(10) & chr(10) & _
"Example: For 55.7.159.1" & chr(10) & _
"Type '1'"
Title = "Start Range"
StartIP = InputBox(Message, Title, "1" )
intStartIP = StartIP
'User Input of End ip
Message = "Please enter End IP Range:" & chr(10) & chr(10) & _
"Example: For 55.7.159.255" & chr(10) & _
"Type '255'"
Title = "End Range"
EndIP = InputBox(Message, Title, "255" )
intEndIP = EndIP
'Problème : Le script ne s'arrête pas lorsque intEndIP est atteind !!
x = intStartIP
Do Until x > intEndIP
strIP = CStr(x)
strComputer = strSubnet & strIP
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2" )
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_PingStatus " & _
"Where Address = '" & strComputer & "'" )
For Each objItem in colItems
If objItem.StatusCode = 0 Then
WScript.Echo (strComputer & " - Reply received." )
Else
WScript.Echo (strComputer & " - No Reply received." )
End If
Next
x = x + 1
Loop