To be honest I have nothing. My scripting experience is VERY limited. I have tried downloading a couple of scripts but nothing has done what I needed it to do.
Thanks, that was a big help. I think I am almost there but having issues combining the 2.
For the ping part, if I run the script below I get the appropriate response...
START
Option Explicit
Dim strHost
' Check that all arguments required have been passed.
If Wscript.Arguments.Count < 1 Then
Wscript.Echo "Arguments <Host> required. For example:" & vbCrLf _
& "cscript vbping.vbs savdaldc01"
Wscript.Quit(0)
End If
strHost = Wscript.Arguments(0)
if Ping(strHost) = True then
Wscript.Echo "Host " & strHost & " contacted"
Else
Wscript.Echo "Host " & strHost & " could not be contacted"
end if
Function Ping(strHost)
dim objPing, objRetStatus
set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select * from Win32_PingStatus where address = '" & strHost & "'")
for each objRetStatus in objPing
if IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode<>0 then
Ping = False
'WScript.Echo "Status code is " & objRetStatus.StatusCode
else
Ping = True
'Wscript.Echo "Bytes = " & vbTab & objRetStatus.BufferSize
'Wscript.Echo "Time (ms) = " & vbTab & objRetStatus.ResponseTime
'Wscript.Echo "TTL (s) = " & vbTab & objRetStatus.ResponseTimeToLive
end if
next
End Function
FINISH
And I can also use this email script and get an email out...
START
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "my email address"
objEmail.To = "my email address"
objEmail.Subject = "Server down"
objEmail.Textbody = "Server1 is no longer accessible over the network."
objEmail.Configuration.Fields.Item _
("
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.