- 论坛徽章:
- 0
|
以前写过一个批处理,不知道有没有用,呵呵。
- @echo off
- <"%~f0" more +27 >getip.vbs
- for /f "delims=: tokens=2" %%i in ('cscript //nologo getIP.vbs') do set "ip=%%i"
- echo NameSpace="http://schemas.microsoft.com/cdo/configuration/" >send.vbs
- echo Set Email=CreateObject("CDO.Message") >>send.vbs
- echo Email.From="发送邮箱" >>send.vbs
- echo Email.To="接收邮箱" >>send.vbs
- echo Email.Subject="TEST" >>send.vbs
- echo Email.Textbody="%ip%" >>send.vbs
- echo With Email.Configuration.Fields >>send.vbs
- echo ^.Item(NameSpace^&"sendusing")=2 >>send.vbs
- echo ^.Item(NameSpace^&"smtpserver")="SMTP服务器" >>send.vbs
- echo ^.Item(NameSpace^&"smtpserverport")=25 >>send.vbs
- echo ^.Item(NameSpace^&"smtpauthenticate")=1 >>send.vbs
- echo ^.Item(NameSpace^&"sendusername")="用户名" >>send.vbs
- echo ^.Item(NameSpace^&"sendpassword")="密码" >>send.vbs
- echo ^.Update >>send.vbs
- echo End With >>send.vbs
- echo Email.Send >>send.vbs
- cscript send.vbs
- del send.vbs
- del getip.vbs
- goto:eof
- set http=createobject("Microsoft.XMLHTTP")
- ipp="http://www.ip138.com"
- http.open "get",ipp,false
- http.send
- ss=bytes2BSTR(Http.responsebody)
- ss=Replace(ss,vbcrlf,"")
- Set re = New RegExp
- re.Pattern = "(.+valign=""top"">)(.+\d+\.\d+\.\d+\.\d+)(.+)"
- re.Global = True
- re.IgnoreCase = True
- re.MultiLine = True
- rv = re.Replace(ss,"$2")
- WScript.Echo rv
- Function bytes2BSTR(vIn)
- strReturn = ""
- For i = 1 To LenB(vIn)
- ThisCharCode = AscB(MidB(vIn,i,1))
- If ThisCharCode < &H80 Then
- strReturn = strReturn & Chr(ThisCharCode)
- Else
- NextCharCode = AscB(MidB(vIn,i+1,1))
- strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
- i = i + 1
- End If
- Next
- bytes2BSTR = strReturn
- End Function
复制代码
在win上建立个计划任务就可以定时发送IP了。 |
|