| auteur : Forum |
Pour Windows Server 2003, XP et supérieur, en utilisant la classe Win32_PingStatus :
VBS |
strComputer = InputBox (" Adresse IP ou Url à 'Pinger' " )
On Error Resume Next
msgbox (" Ping de : " strComputer)
Set objPing = GetObject (" winmgmts:{impersonationLevel=impersonate}!\\ " ). ExecQuery (" select * from Win32_PingStatus where address = ' " & strComputer & " ' " )
For Each objStatus in objPing
If objStatus. Statuscode = 0 Then
msgbox (" TEST OK : " & objStatus. Statuscode )
else
msgbox (" TEST NOK : " & objStatus. Statuscode )
End If
Next
|
Pour Windows 2000, en utilisant l'objet Shell de WScript:
VBS |
strComputer = " 10.169.6.16 "
Set objShell = CreateObject (" WScript.Shell " )
Set objScriptExec = objShell. Exec ( _
" ping -n 2 -w 1000 " & strComputer)
strPingResults = LCase (objScriptExec. StdOut . ReadAll )
If InStr (strPingResults, " perdus = 0 " ) Then
msgbox (strComputer & " repond au ping ! " )
Else
msgbox (strComputer & " na pas repondu au ping! " )
End If
|
|
lien : Microsoft MSDN: Win32_PingStatus
|
| auteur : bbil |
Le code suivant permet d'afficher l'état des configurations des cartes réseaux d'un PC :
VBS |
Computer= InputBox (" Nom de l'ordinateur à tester où rien pour celui-ci : " ," IpConfig " )
On error resume next
set IPConfigSet = GetObject (" winmgmts:{impersonationLevel=impersonate}!// " & Computer). ExecQuery _
(" SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE " )
If Err . Number < > 0 Then
wscript. echo " - non accessible - "
Else
for each IPConfig in IPConfigSet
MsgBox " Configuration réseau de l'ordinateur " & computer & vbcrlf & vbcrlf & _
" Carte " & vbtab & vbtab & " : " & IPConfig. Description & vbcrlf & _
" adresse MAC " & vbtab & " : " & IPConfig. MACAddress & vbcrlf & _
" adresse IP " & vbtab & " : " & IPConfig. IPAddress (0 ) & vbcrlf & _
" DNSHostName " & vbtab & " : " & IPConfig. DNSHostName _
,," Configuration "
Next
End If
|
|
Consultez les autres F.A.Q's
Les sources présentés sur cette pages sont libre de droits,
et vous pouvez les utiliser à votre convenance. Par contre cette page de présentation de ces sources constitue une oeuvre intellectuelle protégée par les droits d'auteurs.
Copyright ©2008
Developpez LLC. Tout droits réservés Developpez LLC.
Aucune reproduction, même partielle, ne peut être faite de ce site et de
l'ensemble de son contenu : textes, documents et images sans l'autorisation
expresse de Developpez LLC. Sinon vous encourez selon la loi jusqu'à 3 ans
de prison et jusqu'à 300 000 E de dommages et intérets.
Cette page est déposée à la SACD.
|