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

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

Set objWShell = CreateObject("WScript.Shell")
Set objCmd = objWShell.Exec("ping " & url)
strPResult = objCmd.StdOut.Readall()
set objCmd = nothing: Set objWShell = nothing

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

response.write url & " is " & strStatus
response.write ".<br>" & replace(strPResult,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

Re: pinging with WScript.Shell by Evertjan

Evertjan
Fri Mar 14 13:44:27 CDT 2008

=?Utf-8?B?VG9kZA==?= wrote on 14 mrt 2008 in
microsoft.public.inetserver.asp.general:

> Hello I'm using the following script to try and ping:
>
> <% Response.Buffer = true %>
> <%
> url = "www.espn.com"
>
> Set objWShell = CreateObject("WScript.Shell")
> Set objCmd = objWShell.Exec("ping " & url)
> strPResult = objCmd.StdOut.Readall()
> set objCmd = nothing: Set objWShell = nothing
>
> strStatus = "offline"
> if InStr(strPResult,"TTL=")>0 then strStatus = "online"
>
> response.write url & " is " & strStatus
> response.write ".<br>" & replace(strPResult,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/technet/scriptcenter/resources/qanda/
sept04/hey0914.mspx>


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

Re: pinging with WScript.Shell by Todd

Todd
Fri Mar 14 14:08:01 CDT 2008



"Evertjan." wrote:

> =?Utf-8?B?VG9kZA==?= wrote on 14 mrt 2008 in
> microsoft.public.inetserver.asp.general:
>
> > Hello I'm using the following script to try and ping:
> >
> > <% Response.Buffer = true %>
> > <%
> > url = "www.espn.com"
> >
> > Set objWShell = CreateObject("WScript.Shell")
> > Set objCmd = objWShell.Exec("ping " & url)
> > strPResult = objCmd.StdOut.Readall()
> > set objCmd = nothing: Set objWShell = nothing
> >
> > strStatus = "offline"
> > if InStr(strPResult,"TTL=")>0 then strStatus = "online"
> >
> > response.write url & " is " & strStatus
> > response.write ".<br>" & replace(strPResult,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/technet/scriptcenter/resources/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("WScript.Shell")
Set objExecObject = objShell.Exec _
("%comspec% /c ping -n 3 -w 1000 192.168.1.1")
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadAll()
If Instr(strText, "Reply") > 0 Then
Wscript.Echo "Reply received."
Else
Wscript.Echo "No reply received."
End If
Loop

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

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
objName = objFSO.GetTempName
objTempFile = objName
objShell.Run "cmd /c ping -n 3 -w 1000 192.168.1.1 >" & _
objTempFile, 0, True
Set objTextFile = objFSO.OpenTextFile(objTempFile, 1)
Do While objTextFile.AtEndOfStream <> True
strText = objTextFile.ReadLine
If Instr(strText, "Reply") > 0 Then
Wscript.Echo "Reply received."
Exit Do
End If
Loop
objTextFile.Close
objFSO.DeleteFile(objTempFile)

Hope this helps narrow down the problem.

Thank You

Re: pinging with WScript.Shell by Bob

Bob
Fri Mar 14 15:11:28 CDT 2008

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

http://classicasp.aspfaq.com/general/how-do-i-execute-a-ping-command-from-asp-and-retrieve-the-results.html

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



Re: pinging with WScript.Shell by p

p
Sat Mar 15 12:08:57 CDT 2008

Hi Bob

I took the example on the page you gave us.

I pasted it into a file called "ping.asp"

I wanted it not particularly for 'Pinging' but to give me a Template
for using WSH in Classic .ASP pages

I am lucky enough to have access to six servers of a whole range of Operating Systems
ranging from ancient to Windows 2003 Server (IIS6)

On all six of them, I got the following Error


======================================
WshShell.Exec error '80070005'

Access is denied.

/test/ping.asp, line 6


======================================

Advice please

Pete (Northolt UK)

"Bob Barrows [MVP]" wrote:

> Todd wrote:
> > Hello I'm using the following script to try and ping:
> >
>
> http://classicasp.aspfaq.com/general/how-do-i-execute-a-ping-command-from-asp-and-retrieve-the-results.html
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.


Re: pinging with WScript.Shell by Bob

Bob
Sat Mar 15 12:24:29 CDT 2008

I was able to get it to work by disabling Anonymous on my test site so that
the wsh code was run under my user context.

If disableing Anonymous is not an option for you, then you need to configure
IIS to use an impersonation account with admin rights on your site. If that
is not an option (and it is not an action I would suggest taking on an
internet site given the security risks involved) then you are out of luck as
far as I know.

p byers wrote:
> Hi Bob
>
> I took the example on the page you gave us.
>
> I pasted it into a file called "ping.asp"
>
> I wanted it not particularly for 'Pinging' but to give me a Template
> for using WSH in Classic .ASP pages
>
> I am lucky enough to have access to six servers of a whole range of
> Operating Systems
> ranging from ancient to Windows 2003 Server (IIS6)
>
> On all six of them, I got the following Error
>
>
> ======================================
> WshShell.Exec error '80070005'
>
> Access is denied.
>
> /test/ping.asp, line 6
>
>
> ======================================
>
> Advice please
>
> Pete (Northolt UK)
>
> "Bob Barrows [MVP]" wrote:
>
>> Todd wrote:
>>> Hello I'm using the following script to try and ping:
>>>
>>
>> http://classicasp.aspfaq.com/general/how-do-i-execute-a-ping-command-from-asp-and-retrieve-the-results.html
>>
>> --
>> Microsoft MVP -- ASP/ASP.NET
>> Please reply to the newsgroup. The email account listed in my From
>> header is my spam trap, so I don't check it very often. You will get
>> a
>> quicker response by posting to the newsgroup.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Re: pinging with WScript.Shell by p

p
Sun Mar 16 03:08:49 CDT 2008

Thanks Bob - will try what you suggest


"Bob Barrows [MVP]" wrote:

> I was able to get it to work by disabling Anonymous on my test site so that
> the wsh code was run under my user context.
>
> If disableing Anonymous is not an option for you, then you need to configure
> IIS to use an impersonation account with admin rights on your site. If that
> is not an option (and it is not an action I would suggest taking on an
> internet site given the security risks involved) then you are out of luck as
> far as I know.
>
> p byers wrote:
> > Hi Bob
> >
> > I took the example on the page you gave us.
> >
> > I pasted it into a file called "ping.asp"
> >
> > I wanted it not particularly for 'Pinging' but to give me a Template
> > for using WSH in Classic .ASP pages
> >
> > I am lucky enough to have access to six servers of a whole range of
> > Operating Systems
> > ranging from ancient to Windows 2003 Server (IIS6)
> >
> > On all six of them, I got the following Error
> >
> >
> > ======================================
> > WshShell.Exec error '80070005'
> >
> > Access is denied.
> >
> > /test/ping.asp, line 6
> >
> >
> > ======================================
> >
> > Advice please
> >
> > Pete (Northolt UK)
> >
> > "Bob Barrows [MVP]" wrote:
> >
> >> Todd wrote:
> >>> Hello I'm using the following script to try and ping:
> >>>
> >>
> >> http://classicasp.aspfaq.com/general/how-do-i-execute-a-ping-command-from-asp-and-retrieve-the-results.html
> >>
> >> --
> >> Microsoft MVP -- ASP/ASP.NET
> >> Please reply to the newsgroup. The email account listed in my From
> >> header is my spam trap, so I don't check it very often. You will get
> >> a
> >> quicker response by posting to the newsgroup.
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"