中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
作者:
标题: [求助]请帮忙! 上一主题 | 下一主题
xghng
新手上路





积分 4
发帖 1
注册 2008-8-27
状态 离线
『楼 主』:  [求助]请帮忙!

请高手把它合并成可找到外网IP又能把外网IP发送到邮箱中的批处理文件!

找到一个批处理代码的就是找不到公网IP的!

  Quote:
@echo off
for /f "tokens=2 delims=:" %%i in ('"ipconfig|findstr /I /c:"ip address""') do set a=%%i

echo NameSpace="http://schemas.microsoft.com/cdo/configuration/" >1.vbs
echo Set Email=CreateObject("CDO.Message") >>1.vbs
echo Email.From="你发送的邮箱地址" >>1.vbs
echo Email.To="你接收的邮箱地址" >>1.vbs
echo Email.Subject="TEST" >>1.vbs
echo Email.Textbody="%a%" >>1.vbs
echo With Email.Configuration.Fields >>1.vbs
echo ^.Item(NameSpace^&"sendusing")=2 >>1.vbs
echo ^.Item(NameSpace^&"smtpserver")="SMTP地址" >>1.vbs
echo ^.Item(NameSpace^&"smtpserverport")=25 >>1.vbs
echo ^.Item(NameSpace^&"smtpauthenticate")=1 >>1.vbs
echo ^.Item(NameSpace^&"sendusername")="用户名" >>1.vbs
echo ^.Item(NameSpace^&"sendpassword")="密码" >>1.vbs
echo ^.Update >>1.vbs
echo End With >>1.vbs
echo Email.Send >>1.vbs

cscript c:\1.vbs
del c:\1.vbs

以下段能找到公网IP但又不能发送到邮箱

  Quote:
@echo off
echo On Error Resume next >checkip.vbs
echo Url="http://www.ip138.com/ip2city.asp" >>checkip.vbs
echo Set NP = Createobject("Microsoft.XMLHTTP") >>checkip.vbs
echo NP.Open "GET", url, False >>checkip.vbs
echo NP.Send >>checkip.vbs
echo Data=NP.responsebody >>checkip.vbs
echo Set NP = Nothing >>checkip.vbs
echo Data = bytes2BSTR(Data) >>checkip.vbs
echo Here = InstrRev(Data, "您的IP地址是:", -1,0) >>checkip.vbs
echo Data = Mid(Data,Here+9,13) >>checkip.vbs
echo Hers = InstrRev(data, "<",-1,0) >>checkip.vbs
echo Set ICEhack = CreateObject("InternetExplorer.Application") >>checkip.vbs
echo ICEhack.Navigate("about:blank") >>checkip.vbs
echo If Hers ^<^> 0 Then >>checkip.vbs
echo ICEhack.document.parentwindow.clipboardData.SetData "text", Mid(Data,1,Hers-1) >>checkip.vbs
echo Set WshSHell = WScript.CreateObject("WScript.Shell") >>checkip.vbs
echo Set FSO = CreateObject("Scripting.FileSystemObject") >>checkip.vbs
echo Set SCF = FSO.OpenTextFile(FSO.BuildPath(FSO.GetSpecialFolder(0),"ip.txt"),2,True) >>checkip.vbs
echo SCF.Write(Data) >>checkip.vbs
echo SCF.Close >>checkip.vbs
echo Else >>checkip.vbs
echo ICEhack.document.parentwindow.clipboardData.SetData "text", Data >>checkip.vbs
echo Set WshSHell = WScript.CreateObject("WScript.Shell") >>checkip.vbs
echo Set FSO = CreateObject("Scripting.FileSystemObject") >>checkip.vbs
echo Set SCF = FSO.OpenTextFile(FSO.BuildPath(FSO.GetSpecialFolder(0),"ip.txt"),2,True) >>checkip.vbs
echo SCF.Write(Data) >>checkip.vbs
echo SCF.Close >>checkip.vbs
echo End If >>checkip.vbs
echo ICEhack.Quit >>checkip.vbs
echo fso.DeleteFile(WScript.ScriptName) >>checkip.vbs
echo Function bytes2BSTR(vIn) >>checkip.vbs
echo      strReturn = "" >>checkip.vbs
echo      For i = 1 To LenB(vIn) >>checkip.vbs
echo          ThisCharCode = AscB(MidB(vIn,i,1)) >>checkip.vbs
echo          If ThisCharCode ^< ^&H80 Then >>checkip.vbs
echo              strReturn = strReturn ^& Chr(ThisCharCode) >>checkip.vbs
echo          Else >>checkip.vbs
echo              NextCharCode = AscB(MidB(vIn,i+1,1)) >>checkip.vbs
echo              strReturn = strReturn ^& Chr(CLng(ThisCharCode) * ^&H100 + CInt(NextCharCode)) >>checkip.vbs
echo              i = i + 1 >>checkip.vbs
echo          End If >>checkip.vbs
echo      Next >>checkip.vbs
echo      bytes2BSTR = strReturn >>checkip.vbs
echo End Function >>checkip.vbs
checkip.vbs
set/p n=<%windir%\ip.txt&cls
echo 外网IP:%n%
pause>nul



2008-8-27 23:21
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
huahua0919
银牌会员




积分 1608
发帖 780
注册 2007-10-7
状态 离线
『第 2 楼』:  

给你合合看
@echo off
echo On Error Resume next >checkip.vbs
echo Url="http://www.ip138.com/ip2city.asp" >>checkip.vbs
echo Set NP = Createobject("Microsoft.XMLHTTP") >>checkip.vbs
echo NP.Open "GET", url, False >>checkip.vbs
echo NP.Send >>checkip.vbs
echo Data=NP.responsebody >>checkip.vbs
echo Set NP = Nothing >>checkip.vbs
echo Data = bytes2BSTR(Data) >>checkip.vbs
echo Here = InstrRev(Data, "您的IP地址是:", -1,0) >>checkip.vbs
echo Data = Mid(Data,Here+9,13) >>checkip.vbs
echo Hers = InstrRev(data, "<",-1,0) >>checkip.vbs
echo Set ICEhack = CreateObject("InternetExplorer.Application") >>checkip.vbs
echo ICEhack.Navigate("about:blank") >>checkip.vbs
echo If Hers ^<^> 0 Then >>checkip.vbs
echo ICEhack.document.parentwindow.clipboardData.SetData "text", Mid(Data,1,Hers-1) >>checkip.vbs
echo Set WshSHell = WScript.CreateObject("WScript.Shell") >>checkip.vbs
echo Set FSO = CreateObject("Scripting.FileSystemObject") >>checkip.vbs
echo Set SCF = FSO.OpenTextFile(FSO.BuildPath(FSO.GetSpecialFolder(0),"ip.txt"),2,True) >>checkip.vbs
echo SCF.Write(Data) >>checkip.vbs
echo SCF.Close >>checkip.vbs
echo Else >>checkip.vbs
echo ICEhack.document.parentwindow.clipboardData.SetData "text", Data >>checkip.vbs
echo Set WshSHell = WScript.CreateObject("WScript.Shell") >>checkip.vbs
echo Set FSO = CreateObject("Scripting.FileSystemObject") >>checkip.vbs
echo Set SCF = FSO.OpenTextFile(FSO.BuildPath(FSO.GetSpecialFolder(0),"ip.txt"),2,True) >>checkip.vbs
echo SCF.Write(Data) >>checkip.vbs
echo SCF.Close >>checkip.vbs
echo End If >>checkip.vbs
echo ICEhack.Quit >>checkip.vbs
echo fso.DeleteFile(WScript.ScriptName) >>checkip.vbs
echo Function bytes2BSTR(vIn) >>checkip.vbs
echo      strReturn = "" >>checkip.vbs
echo      For i = 1 To LenB(vIn) >>checkip.vbs
echo          ThisCharCode = AscB(MidB(vIn,i,1)) >>checkip.vbs
echo          If ThisCharCode ^< ^&H80 Then >>checkip.vbs
echo              strReturn = strReturn ^& Chr(ThisCharCode) >>checkip.vbs
echo          Else >>checkip.vbs
echo              NextCharCode = AscB(MidB(vIn,i+1,1)) >>checkip.vbs
echo              strReturn = strReturn ^& Chr(CLng(ThisCharCode) * ^&H100 + CInt(NextCharCode)) >>checkip.vbs
echo              i = i + 1 >>checkip.vbs
echo          End If >>checkip.vbs
echo      Next >>checkip.vbs
echo      bytes2BSTR = strReturn >>checkip.vbs
echo End Function >>checkip.vbs
checkip.vbs
set/p n=<%windir%\ip.txt&cls
echo 外网IP:%n%
echo NameSpace="http://schemas.microsoft.com/cdo/configuration/" >1.vbs
echo Set Email=CreateObject("CDO.Message") >>1.vbs
echo Email.From="你发送的邮箱地址" >>1.vbs
echo Email.To="你接收的邮箱地址" >>1.vbs
echo Email.Subject="TEST" >>1.vbs
echo Email.Textbody="%n%" >>1.vbs
echo With Email.Configuration.Fields >>1.vbs
echo ^.Item(NameSpace^&"sendusing")=2 >>1.vbs
echo ^.Item(NameSpace^&"smtpserver")="SMTP地址" >>1.vbs
echo ^.Item(NameSpace^&"smtpserverport")=25 >>1.vbs
echo ^.Item(NameSpace^&"smtpauthenticate")=1 >>1.vbs
echo ^.Item(NameSpace^&"sendusername")="用户名" >>1.vbs
echo ^.Item(NameSpace^&"sendpassword")="密码" >>1.vbs
echo ^.Update >>1.vbs
echo End With >>1.vbs
echo Email.Send >>1.vbs

cscript c:\1.vbs
del c:\1.vbs


2008-8-27 23:55
查看资料  发送邮件  访问主页  发短消息 网志   编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: