|
nblue
初级用户
 
积分 117
发帖 37
注册 2006-6-8
状态 离线
|
『楼 主』:
关于用批处理发送IP到邮箱的另一问题?
使用 LLM 解释/回答一下
前些日子在本坛发了一个如何用批处理发送IP到邮箱的问题,得到坛里的朋友们指指点点。本人受益非浅,但本人对这方面的知识实在太菜,还有一问题不能解决。唯有再发此贴请求高人指点。
原批处理代码:
@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发到邮箱,但如果没有联网,那就会出错。如何修改命令使批处理在系统联网的情况下才运行,在没联网的时候不运行或不出错误显示?
A few days ago, I posted a question in this forum about how to use batch processing to send the IP to the email, and got the pointers from the friends in the forum. I have benefited a lot, but I am really weak in this aspect of knowledge, and there is still a problem that cannot be solved. I have to post this post again to ask the experts for guidance.
Original batch processing code:
@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="your sending email address" >>1.vbs
echo Email.To="your receiving email address" >>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 address" >>1.vbs
echo ^.Item(NameSpace^&"smtpserverport")=25 >>1.vbs
echo ^.Item(NameSpace^&"smtpauthenticate")=1 >>1.vbs
echo ^.Item(NameSpace^&"sendusername")="username" >>1.vbs
echo ^.Item(NameSpace^&"sendpassword")="password" >>1.vbs
echo ^.Update >>1.vbs
echo End With >>1.vbs
echo Email.Send >>1.vbs
cscript c:\1.vbs
del c:\1.vbs
Problem: When connected to the Internet, the batch processing runs and can successfully send the IP to the email, but if not connected to the Internet, it will be wrong. How to modify the command so that the batch processing runs only when the system is connected to the Internet, and does not run or does not display errors when not connected to the Internet?
|
|
2006-6-16 11:16 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
把倒数第二句改一下试试:
cscript c:\1.vbs 1>nul 2>nul||echo 发送错误...
没有经过实验,请楼主实验后报告一下情况,谢谢........
cscript c:\1.vbs 1>nul 2>nul||echo Sending error...
No experiment has been conducted, please the original poster to report the situation after the experiment, thank you........
|
|
2006-6-16 11:31 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
可以尝试以下代码,上面的可能不成:
@echo off
for /f "tokens=2 delims=:" %%i in ('"ipconfig|findstr /I /c:"ip address""') do set a=%%i
echo on error resume next >1.txt
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
echo if err.number^<^>0 then>>1.vbs
echo wscript.echo 发送错误......>>1.vbs
echo wscript.quit >>1.vbs
echo end if >>1.vbs
cscript c:\1.vbs
del c:\1.vbs
没有经过测试,请测试后报告,谢谢
You can try the following code, the above may not work:
@echo off
for /f "tokens=2 delims=:" %%i in ('"ipconfig|findstr /I /c:"ip address""') do set a=%%i
echo on error resume next >1.txt
echo NameSpace="http://schemas.microsoft.com/cdo/configuration/" >>1.vbs
echo Set Email=CreateObject("CDO.Message") >>1.vbs
echo Email.From="your sending email address" >>1.vbs
echo Email.To="your receiving email address" >>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 address" >>1.vbs
echo ^.Item(NameSpace^&"smtpserverport")=25 >>1.vbs
echo ^.Item(NameSpace^&"smtpauthenticate")=1 >>1.vbs
echo ^.Item(NameSpace^&"sendusername")="username" >>1.vbs
echo ^.Item(NameSpace^&"sendpassword")="password" >>1.vbs
echo ^.Update >>1.vbs
echo End With >>1.vbs
echo Email.Send >>1.vbs
echo if err.number^<^>0 then>>1.vbs
echo wscript.echo 发送错误......>>1.vbs
echo wscript.quit >>1.vbs
echo end if >>1.vbs
cscript c:\1.vbs
del c:\1.vbs
Not tested, please report after testing, thank you
|
|
2006-6-16 12:02 |
|
|
nblue
初级用户
 
积分 117
发帖 37
注册 2006-6-8
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
测试平台:WINDOWS XP
测试机型:1,IBM T60(新系统) 2,兼容机
测试次数:20次以上
设原来的批处理为A, 有隐藏错误功能的批处理为B。测试方法:
1,联网情况下:运行A能成功发送IP到邮箱,但有窗口出现,约15秒消失;运行B出现错误提示“c:\1.vbs<18,14>microsoft vbscript 编译器错误:无效字符”,有窗口出现,10秒左右消失窗口。
2,断网情况下:运行A有运行窗口出现,在IBM T60一闪而过,在兼容机需要几秒钟后才消失。运行B时,在IBM T60一闪而过。在兼容机上还没试
Test platform: WINDOWS XP
Test models: 1, IBM T60 (new system) 2, compatible machine
Number of tests: more than 20 times
Let the original batch processing be A, and the batch processing with hidden error function be B. Test method:
1. Under network connection: Running A can successfully send IP to the email, but there is a window appearing, which disappears in about 15 seconds; running B has an error prompt "c:\1.vbs<18,14>microsoft vbscript compiler error: invalid character", there is a window appearing, and the window disappears in about 10 seconds.
2. Under offline condition: Running A has a running window appearing, on IBM T60 it flashes by in a flash, and on the compatible machine it takes a few seconds to disappear. When running B, on IBM T60 it flashes by in a flash. It hasn't been tested on the compatible machine yet
|
|
2006-6-16 18:04 |
|
|
nblue
初级用户
 
积分 117
发帖 37
注册 2006-6-8
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
我在测试中,发现不是每次运行批处理就会发送IP的。大概运行四五次才有一次成功发送
I'm testing, and I find that the IP isn't sent every time the batch script runs. It succeeds in sending only about once every four or five runs.
|
|
2006-6-16 18:05 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
这个应该是 邮件服务器的问题,响应慢了~~我连QQ邮箱也是要尝试5次以上的~~
This should be a problem with the email server, it's slow to respond~~ I also need to try more than 5 times to connect to QQ Mail~~
|

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" |
|
2006-6-16 18:12 |
|
|
nblue
初级用户
 
积分 117
发帖 37
注册 2006-6-8
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
Originally posted by electronixtar at 2006-6-16 18:12:
这个应该是 邮件服务器的问题,响应慢了~~我连QQ邮箱也是要尝试5次以上的~~
是的
Originally posted by electronixtar at 2006-6-16 18:12:
This should be a problem with the email server, it's slow to respond~~ I also need to try more than 5 times to connect to QQ Mail~~
Yes
|
|
2006-6-16 18:18 |
|
|
nblue
初级用户
 
积分 117
发帖 37
注册 2006-6-8
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
呵呵,那位高手网友bagpipe做了一个佛字,本人依赫尔葫芦画瓢做了一个神字,见笑了
Hehe, the expert netizen bagpipe made a "Buddha" character, and I imitated it to make a "God" character. Please excuse the crudeness.
|
|
2006-6-16 18:30 |
|