码迷,mamicode.com
首页 > 其他好文 > 详细

[服务器]脚本:批处理带参数ping命令 发送邮件脚本

时间:2015-03-31 12:11:40      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:

1、批处理带参数ping命令

@echo off
echo Input you IP address ......
set /p IP=
echo Your IP number is %IP%.
ping %IP%
set IP=
pause

 

2、发送告警脚本

For counter = 1 To 3 Step 1
SendMail
Next

Public Sub SendMail
NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = CreateObject("CDO.Message")
Email.From = "Server" ‘发件人名称
Email.To = "test@test.com.cn" ‘收件人邮件地址
Email.Subject = GetIP&" 温度告警!" ‘邮件主题
MsgBox(email.subject) 调试用
Email.Textbody="Test" ‘邮件内容
With Email.Configuration.Fields
.Item(NameSpace&"sendusing") = 2
.Item(NameSpace&"smtpserver") = "test.com.cn" ‘SMTP服务器地址
.Item(NameSpace&"smtpserverport") = 25 ‘SMTP服务器端口
.Item(NameSpace&"smtpauthenticate") = 1 ‘SMTP身份验证
.Item(NameSpace&"sendusername") = "test" ‘发件帐号
.Item(NameSpace&"sendpassword") = "test" ‘发件密码
.Update
End With
Email.Send
End Sub

Public Function GetIP
ComputerName="."
Dim objWMIService,colItems,objItem,objAddress
Set objWMIService = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
For Each objAddress in objItem.IPAddress
If objAddress <> "" then
GetIP = objAddress
Exit Function
End If
Next
Next
End Function

[服务器]脚本:批处理带参数ping命令 发送邮件脚本

标签:

原文地址:http://www.cnblogs.com/viphhs/p/4380151.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!