1. Batch processing with the parameter ping command
@echo off
echo Input you IP address ...
set/p ip=
echo Your IP number is%ip%.
Ping%ip%
Set ip=
Pause
2. Send Alarm Script
For counter = 1 to 3 Step 1
SendMail
Next
Public Sub SendMail
NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = CreateObject (" Cdos. Message ")
Email.from =" Server "' sender name
email.to =" [email protected] "' Recipient e-mail address
Email.subject = GetIP & "Temperature Alarm! "' Message subject
MsgBox (email.subject) debugging with
email.textbody=" Test "' message content
with Email.Configuration.Fields
. Item (namespace& "sendusing") = 2
. Item (namespace& "smtpserver") = "test.com.cn" ' SMTP server address
. Item (namespace& "smtpserverport") = "SMTP Server port
." Item (namespace& "smtpauthenticate") = 1 ' SMTP authentication
. Item (namespace& "sendusername") = "test" ' Sender account
. Item (namespace& "sendpassword") = "test" ' Sender password
. 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
[Server] Script: Batch with parameter ping command send mail script