[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] 批处理如何将txt文本内容输出到cmd命令行中?

因为小弟想通过批处理命令行发送邮件,但是邮件的内容想从txt文档或者log文档中导入到cmd命令行中,请大神帮助实现啊,在线等谢谢!
  1. @echo off
  2. @del temp.vbs
  3. @echo on error resume next >>temp.vbs
  4. @echo dim WshShell,txt>>temp.vbs
  5. @echo Set WshShell = WScript.CreateObject("WScript.Shell")>>temp.vbs
  6. @echo WshShell.run"cmd">>temp.vbs
  7. @echo WshShell.AppActivate"c:\windows\system32\cmd.exe">>temp.vbs
  8. @echo WScript.Sleep 200>>temp.vbs
  9. @echo WshShell.SendKeys"telnet smtp.163.com 25{ENTER}">>temp.vbs
  10. @echo WScript.Sleep 200>>temp.vbs
  11. @echo WshShell.SendKeys"helo localhost{ENTER}">>temp.vbs
  12. @echo WScript.Sleep 200>>temp.vbs
  13. @echo WshShell.SendKeys"auth login{ENTER}">>temp.vbs
  14. @echo WScript.Sleep 200>>temp.vbs
  15. @echo WshShell.SendKeys"name{ENTER}">>temp.vbs
  16. @echo WScript.Sleep 200>>temp.vbs
  17. @echo WshShell.SendKeys"password{ENTER}">>temp.vbs
  18. @echo WScript.Sleep 200>>temp.vbs
  19. @echo WshShell.SendKeys"mail from : <xxxx@163.com>{ENTER}">>temp.vbs
  20. @echo WScript.Sleep 200>>temp.vbs
  21. @echo WshShell.SendKeys"rcpt to : <xxxxx@qq.com>{ENTER}">>temp.vbs
  22. @echo WScript.Sleep 200>>temp.vbs
  23. @echo WshShell.SendKeys"data{ENTER}">>temp.vbs
  24. @echo WScript.Sleep 200>>temp.vbs
  25. @echo WshShell.SendKeys"subject : test{ENTER}{ENTER}">>temp.vbs
  26. @echo WScript.Sleep 200>>temp.vbs
  27. @echo WshShell.SendKeys"test from myself {ENTER}">>temp.vbs
  28. @echo WshShell.SendKeys".{ENTER}">>temp.vbs
  29. @call temp.vbs
复制代码

回复 2# apang

真的非常感谢,试了一下完全OK

TOP

发送c:\a.txt 文本内容,试试看吧:
  1. @echo off
  2. del temp.vbs
  3. (
  4.     echo on error resume next
  5.     echo dim WshShell,fso,str
  6.     echo set fso = createobject^("scripting.filesystemobject"^)
  7.     echo str = fso.opentextfile^("c:\a.txt"^).readall
  8.     echo Set WshShell = WScript.CreateObject^("WScript.Shell"^)
  9.     echo WshShell.run"cmd"
  10.     echo WshShell.AppActivate"c:\windows\system32\cmd.exe"
  11.     echo WScript.Sleep 200
  12.     echo WshShell.SendKeys"telnet smtp.163.com 25{ENTER}"
  13.     echo WScript.Sleep 200
  14.     echo WshShell.SendKeys"helo localhost{ENTER}"
  15.     echo WScript.Sleep 200
  16.     echo WshShell.SendKeys"auth login{ENTER}"
  17.     echo WScript.Sleep 200
  18.     echo WshShell.SendKeys"name{ENTER}" 'base64加密后的用户名
  19.     echo WScript.Sleep 200
  20.     echo WshShell.SendKeys"password{ENTER}" 'base64加密后的密码
  21.     echo WScript.Sleep 200
  22.     echo WshShell.SendKeys"mail from : <xxx@163.com>{ENTER}"
  23.     echo WScript.Sleep 200
  24.     echo WshShell.SendKeys"rcpt to : <xxx@qq.com>{ENTER}"
  25.     echo WScript.Sleep 200
  26.     echo WshShell.SendKeys"data{ENTER}"
  27.     echo WScript.Sleep 200
  28.     echo WshShell.SendKeys"subject : test{ENTER}{ENTER}"
  29.     echo WScript.Sleep 200
  30.     echo WshShell.SendKeys str ^& "{ENTER}"
  31.     echo WshShell.SendKeys".{ENTER}"
  32. )>temp.vbs
  33. call temp.vbs
复制代码
1

评分人数

    • lxfka: 完全实现了要求,谢谢!就是测试时使用的lo ...技术 + 1

TOP

返回列表