Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WshShell.Exec Error '800700002'

Status
Not open for further replies.

JCMILBURN

IS-IT--Management
Sep 25, 2002
5
US
Looking for some help with this error from the prograqmming deities on this site. :)

WshShell.Exec
Error '80070002'
The system cannnot find the file specified
Line, 5

I am trying to include this ASP page below to preform a ping on IP addresses and I keep getting the error above.

What's crazy is I have a win2000 server that this code works fine on. However I am now trying to run this same code on a win2003 server and I keep getting this error.

My eyes are starting to glass over from reading junk off the MSDN web site about WMI and IIS. Can someone please point me in the right direction before I pass out.. LOL :)

<%
function PingStats(IPAddress)
url = IPAddress
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"
Pingstats = strStatus & "," & strPResult
'response.write url & " is " & strStatus
'response.write ".<br>" & replace(strPResult,vbCrLf,"<br>")
End function
%>
 
Update,

I have changed the code to run as it's own asp page and now I get this error.
WshShell.Exec
error '80070005'

Access is denied
Line 6


<% Response.Buffer = true %>
<%
url = "172.20.36.86"

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>")
%>
 
Approched the problem from a different angle and it worked.

strHostName = Mid(objRS("IP"),1,LEN(objRS("IP"))-3)

strQuery = "SELECT * FROM Win32_PingStatus WHERE Address = '" & strHostName & "'"
Set colPingResults = GetObject("winmgmts://./root/cimv2").ExecQuery( strQuery )

For Each objPingResult In colPingResults
If Not IsObject( objPingResult ) Then
strPingResult = False
ElseIf objPingResult.StatusCode = 0 Then
strPingResult = True
Else
strPingResult = False
End If
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top