Board logo

标题: 求一个开机自动检测网络的VBS [打印本页]

作者: zinet    时间: 2009-2-26 21:54     标题: 求一个开机自动检测网络的VBS

电脑开机后5分钟,自动运行该vbs,vbs运行后ping一个为www.xxx.cn的网站,如果能ping通的话就打开www.xxx.cn/index.html,不能ping通的话就自动退出该vbs ,不知该vbs如何写请高人指教,谢谢
作者: leaparde    时间: 2009-2-27 11:03     标题: 回复 1楼 的帖子

  1. @ping www.xx.cn -n 2 |findstr TTL>nul&&(start www.xxx.cn/index.html)||exit
复制代码
开机自动运行的话你自己加吧,我不会弄,呵呵
作者: Batcher    时间: 2009-2-27 11:13     标题: 回复 2楼 的帖子

你这个不是VBS代码吧?
作者: rat    时间: 2009-3-26 22:12

  1. WSH.Sleep 1000 * 60 * 5
  2. If Ping("www.xxx.cn") Then
  3. OpenIE("www.xxx.cn/index.html")
  4. End If
  5. Sub OpenIE(strWeb)
  6. CreateObject("WScript.Shell").Run "iexplore " + strWeb
  7. End Sub
  8. Function Ping(strHost)
  9. b = False
  10. strComputer = strHost
  11. Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
  12. Set colItems = objWMIService.ExecQuery _
  13. ("Select * from Win32_PingStatus " & _
  14. "Where Address = '" & strComputer & "'")
  15. For Each objItem in colItems
  16. If objItem.StatusCode = 0 Then
  17. b = True
  18. Exit For
  19. End If
  20. Next
  21. Ping = b
  22. End Function
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2