⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sol12-11.vbs

📁 Apress - Managing Enterprise Systems With The Windows Script Host Source Code
💻 VBS
字号:
'Script: ISAlive.VBS
'Description
'Checks if machines are unavailable and E-maile-mails a specified user
'if can't reach machines (machines might be down)
Dim objPing, strResult, objMail
Set objPing = CreateObject("SScripting.IPNetwork")

strResult = ""
Ping "Mars", strResult
Ping "Jupiter", strResult
Ping "Thor", strResult

'check if the return result is not empty - if not empty, then unable to ping
'one or more machines
If strResult <> "" Then
 sResult = "Unable to contact following machines:" & vbCrLf & sResult
 Set objMail = CreateObject("CDO.Send")
 objMail.Profile = "SCB"
 objMail.Logon
 objMail.NewMessage
 objMail.AddRecipient "SMTP:administrator@c3i.com"
 objMail.Message = "Machine(s) Not Available "
 objMail.Subject = strResult
 objMail.Send
 objMail.Logoff
End If

Sub Ping(strHost, ByRef strMsg)
  If Not objPing.Ping(strHost) = 0 Then strMsg = strMsg & strHost & vbCrLf
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -