pinging with WScript.Shell

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?VG9kZA==?=

    pinging with WScript.Shell

    Hello I'm using the following script to try and ping:

    <% Response.Buffer = true %>
    <%
    url = "www.espn.c om"

    Set objWShell = CreateObject("W Script.Shell")
    Set objCmd = objWShell.Exec( "ping " & url)
    strPResult = objCmd.StdOut.R eadall()
    set objCmd = nothing: Set objWShell = nothing

    strStatus = "offline"
    if InStr(strPResul t,"TTL=")>0 then strStatus = "online"

    response.write url & " is " & strStatus
    response.write ".<br>" & replace(strPRes ult,vbCrLf,"<br >")
    %>

    I am getting the following error on the objWShell.Exec( "ping " & url):

    WshShell.Exec error '80070005'

    Access is denied.

    /test.asp, line 6


    I can understand there being permssions errors if I was moving files around
    in different directories but this is a straight ping. There shouldnt be any
    permissions error by my thinking. Any help would be appreciated.

    Thank You

  • Evertjan.

    #2
    Re: pinging with WScript.Shell

    =?Utf-8?B?VG9kZA==?= wrote on 14 mrt 2008 in
    microsoft.publi c.inetserver.as p.general:
    Hello I'm using the following script to try and ping:
    >
    <% Response.Buffer = true %>
    <%
    url = "www.espn.c om"
    >
    Set objWShell = CreateObject("W Script.Shell")
    Set objCmd = objWShell.Exec( "ping " & url)
    strPResult = objCmd.StdOut.R eadall()
    set objCmd = nothing: Set objWShell = nothing
    >
    strStatus = "offline"
    if InStr(strPResul t,"TTL=")>0 then strStatus = "online"
    >
    response.write url & " is " & strStatus
    response.write ".<br>" & replace(strPRes ult,vbCrLf,"<br >")
    %>
    >
    I am getting the following error on the objWShell.Exec( "ping " & url):
    >
    WshShell.Exec error '80070005'
    >
    Access is denied.
    >
    /test.asp, line 6
    >
    >
    I can understand there being permssions errors if I was moving files
    around in different directories but this is a straight ping. There
    shouldnt be any permissions error by my thinking. Any help would be
    appreciated.
    read this perhaps:

    <http://www.microsoft.com.nsatc.net/t...sources/qanda/
    sept04/hey0914.mspx>


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • =?Utf-8?B?VG9kZA==?=

      #3
      Re: pinging with WScript.Shell



      "Evertjan." wrote:
      =?Utf-8?B?VG9kZA==?= wrote on 14 mrt 2008 in
      microsoft.publi c.inetserver.as p.general:
      >
      Hello I'm using the following script to try and ping:

      <% Response.Buffer = true %>
      <%
      url = "www.espn.c om"

      Set objWShell = CreateObject("W Script.Shell")
      Set objCmd = objWShell.Exec( "ping " & url)
      strPResult = objCmd.StdOut.R eadall()
      set objCmd = nothing: Set objWShell = nothing

      strStatus = "offline"
      if InStr(strPResul t,"TTL=")>0 then strStatus = "online"

      response.write url & " is " & strStatus
      response.write ".<br>" & replace(strPRes ult,vbCrLf,"<br >")
      %>

      I am getting the following error on the objWShell.Exec( "ping " & url):

      WshShell.Exec error '80070005'

      Access is denied.

      /test.asp, line 6


      I can understand there being permssions errors if I was moving files
      around in different directories but this is a straight ping. There
      shouldnt be any permissions error by my thinking. Any help would be
      appreciated.
      >
      read this perhaps:
      >
      <http://www.microsoft.com.nsatc.net/t...sources/qanda/
      sept04/hey0914.mspx>
      >
      >
      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)
      >
      Tried both Win 2000 options on that site and getting the same errors at the
      same locations (.Exec on the first one and .Run on the second. For your
      convenience here si the two scripts I tried running (replacing the IP with
      something local to me).

      Set objShell = CreateObject("W Script.Shell")
      Set objExecObject = objShell.Exec _
      ("%comspec% /c ping -n 3 -w 1000 192.168.1.1")
      Do While Not objExecObject.S tdOut.AtEndOfSt ream
      strText = objExecObject.S tdOut.ReadAll()
      If Instr(strText, "Reply") 0 Then
      Wscript.Echo "Reply received."
      Else
      Wscript.Echo "No reply received."
      End If
      Loop

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

      Set objFSO = CreateObject("S cripting.FileSy stemObject")
      Set objShell = CreateObject("W script.Shell")
      objName = objFSO.GetTempN ame
      objTempFile = objName
      objShell.Run "cmd /c ping -n 3 -w 1000 192.168.1.1 >" & _
      objTempFile, 0, True
      Set objTextFile = objFSO.OpenText File(objTempFil e, 1)
      Do While objTextFile.AtE ndOfStream <True
      strText = objTextFile.Rea dLine
      If Instr(strText, "Reply") 0 Then
      Wscript.Echo "Reply received."
      Exit Do
      End If
      Loop
      objTextFile.Clo se
      objFSO.DeleteFi le(objTempFile)

      Hope this helps narrow down the problem.

      Thank You

      Comment

      Working...