标签:
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
标签:
原文地址:http://www.cnblogs.com/viphhs/p/4380151.html