Home > Archive > ASP > March 2008 > pinging with WScript.Shell
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
pinging with WScript.Shell
|
|
|
| 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
| |
| Evertjan. 2008-03-14, 6:59 pm |
| =?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/...esources/qanda/
sept04/hey0914.mspx>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
| |
|
|
"Evertjan." wrote:
> =?Utf-8?B?VG9kZA==?= wrote on 14 mrt 2008 in
> microsoft.public.inetserver.asp.general:
>
>
> read this perhaps:
>
> <http://www.microsoft.com.nsatc.net/...esources/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
| |
| Bob Barrows [MVP] 2008-03-14, 6:59 pm |
| Todd wrote:
> Hello I'm using the following script to try and ping:
>
http://classicasp.aspfaq.com/genera...he-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.
| |
| p byers 2008-03-15, 6:58 pm |
| 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:
>
> http://classicasp.aspfaq.com/genera...he-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.
| |
| Bob Barrows [MVP] 2008-03-15, 6:58 pm |
| 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:[color=darkred]
> 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:
>
--
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"
| |
| p byers 2008-03-16, 4:13 am |
| 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:
>
> --
> 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"
|
|
|
|
|