Red de conocimientos turísticos - Conocimientos sobre calendario chino - ¡Acerca del problema de la implementación de ping por parte de ASP! ~

¡Acerca del problema de la implementación de ping por parte de ASP! ~

Se puede lograr, necesita soporte para el componente WScript.Shell.

Te doy el código:

lt;

Set FileSys = Server.CreateObject("Scripting.FileSystemObject")

FileName = FileSys .GetTempName

Establecer WShShell = Server.CreateObject("WScript.Shell")

IP = "127.0.0.1" ' dirección IP

RetCode = WShShell Ejecutar("d:\DoPing.bat " & IP & " " & FileName, 1, True)

si RetCode = 0 Entonces

si no

. respuesta.escribir "¡Error!"

end if

Establecer TextFile = FileSys.OpenTextFile("d:\" amp; FileName amp; ".txt", 1)

TextBuffer = TextFile.ReadAll

Para i = 1 a Len(TextBuffer)

Si Mid(TextBuffer, i, 1) = chr(13) Entonces

Response.Write("lt;BRgt;")

else

Response.Write(Mid(TextBuffer, i, 1))

end if

Siguiente

TextFile.Close

FileSys.DeleteFile "d:\" amp FileName amp ".txt"

gt;

Luego cree un archivo bat en D:\, el contenido es:

ping -a 1 gt:\2.txt

----------------------

Otro método es registrar un componente aspping. Se llama aspping.dll, búscalo.