This little Vbscript allows you to ping a site and send email, if the site is down
Dim strWebsite
strWebsite = "sitename.com"
If PingSite( strWebsite ) Then
Else
Set myMail=CreateObject("CDO.Message")
myMail.Subject="SITE is Down"
myMail.From = fromemailaddress
myMail.To = toemailaddress
myMail.HTMLBody= strWebsite
myMail.Send
set myMail=nothing
End If
Function PingSite( myWebsite ) Dim siteStatus, objHTTP
Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
objHTTP.Open "GET", "http://" & myWebsite & "/", False
objHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)"
On Error Resume Next
objHTTP.Send
siteStatus = objHTTP.Status
On Error Goto 0
If siteStatus = 200 Then
PingSite = True
Else
PingSite = False
End If
Set objHTTP = Nothing
End Function
"Scripting" is basically giving sequential instructions to computer for doing specific things rather than doing manually. Sometimes we need to write a small and quick vbscript (.vbs), javascript(.js), batch file(.bat) or SQL script(.sql) to perform a short task, but we lack information or get confuse on where to start or which scrpit to write. In my BLOG, I will try to cover as many different scripts as possible that will be useful to everyone.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment