-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebsite_Check_textOutput.vbs
57 lines (40 loc) · 1.37 KB
/
website_Check_textOutput.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Dim strWebsite
Dim fso
Set fso = WScript.CreateObject("Scripting.Filesystemobject")
Set f = fso.OpenTextFile("links_status.txt", 2)
'------------------------------------
strWebsite = "http://mmkndscmepp:50000/irj/portal"
StatusThrow(strWebsite)
'------------------------------------
f.Close
Function StatusThrow(strWebsite)
If PingSite(strWebsite) Then
f.WriteLine "Website " & strWebsite & " is UP"
Else
f.WriteLine "Website " & strWebsite & " is DOWN"
End If
End Function
Function PingSite(strWebsite)
' This function checks if a website is running by sending an HTTP request.
' If the website is up, the function returns True, otherwise it returns False.
' Argument: myWebsite [string] in "www.domain.tld" format, without the
' "http://" prefix.
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com
' "WinHttp.WinHttpRequest.5.1"
Dim intStatus, objHTTP
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
objHTTP.Open "GET", strWebsite, False
' objHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)"
On Error Resume Next
objHTTP.Send
intStatus = objHTTP.Status
On Error Goto 0
If intStatus = 200 Then
PingSite = True
Else
PingSite = False
End If
Set objHTTP = Nothing
End Function