Ping
Fermé
soumoum
-
9 juil. 2008 à 14:29
zavenger Messages postés 811 Date d'inscription vendredi 29 février 2008 Statut Membre Dernière intervention 20 avril 2012 - 9 juil. 2008 à 14:45
zavenger Messages postés 811 Date d'inscription vendredi 29 février 2008 Statut Membre Dernière intervention 20 avril 2012 - 9 juil. 2008 à 14:45
2 réponses
bonjour,
petit script dos :
petit script dos :
@echo OFF ping xxx.xxx.xxx.xxx goto A%ERRORLEVEL% A0: echo OK goto fin A1: echo ERREUR :fin
zavenger
Messages postés
811
Date d'inscription
vendredi 29 février 2008
Statut
Membre
Dernière intervention
20 avril 2012
161
9 juil. 2008 à 14:45
9 juil. 2008 à 14:45
bonjour, voici un efonction ping en vbs, normalement elle fonctionne sous xp
Function Ping( myHostName )
' This function returns True if the specified host could be pinged.
' myHostName can be a computer name or IP address.
' The Win32_PingStatus class used in this function requires Windows XP or later.
' This function is based on the TestPing function in a sample script by Don Jones
' https://www.sapien.com/forums/viewforum.php?f=6#activedirectoryquickworkstationinventorytxt
' Standard housekeeping
Dim colPingResults, objPingResult, strQuery
' Define the WMI query
strQuery = "SELECT * FROM Win32_PingStatus WHERE Address = '" & myHostName & "'"
' Run the WMI query
Set colPingResults = GetObject("winmgmts://./root/cimv2").ExecQuery( strQuery )
' Translate the query results to either True or False
For Each objPingResult In colPingResults
If Not IsObject( objPingResult ) Then
Ping = False
ElseIf objPingResult.StatusCode = 0 Then
Ping = True
Else
Ping = False
End If
Next
End Function
Function Ping( myHostName )
' This function returns True if the specified host could be pinged.
' myHostName can be a computer name or IP address.
' The Win32_PingStatus class used in this function requires Windows XP or later.
' This function is based on the TestPing function in a sample script by Don Jones
' https://www.sapien.com/forums/viewforum.php?f=6#activedirectoryquickworkstationinventorytxt
' Standard housekeeping
Dim colPingResults, objPingResult, strQuery
' Define the WMI query
strQuery = "SELECT * FROM Win32_PingStatus WHERE Address = '" & myHostName & "'"
' Run the WMI query
Set colPingResults = GetObject("winmgmts://./root/cimv2").ExecQuery( strQuery )
' Translate the query results to either True or False
For Each objPingResult In colPingResults
If Not IsObject( objPingResult ) Then
Ping = False
ElseIf objPingResult.StatusCode = 0 Then
Ping = True
Else
Ping = False
End If
Next
End Function
9 juil. 2008 à 14:45