找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 20297|回复: 6

[问题求助] [已解决]vbs代码,会连续弹出2个对话框。能否放在1个对话框里面,同时显示2个内容?

[复制链接]
发表于 2015-12-22 13:24:07 | 显示全部楼层 |阅读模式
本帖最后由 ygqiang 于 2015-12-22 21:47 编辑

[已解决]vbs代码,会连续弹出2个对话框。能否放在1个对话框里面,同时显示2个内容?
  1. '判断网络是否畅通,当大于500毫秒即判断为超时。
  2. Set ws = WScript.CreateObject("WScript.Shell")
  3. TheIP = "192.168.11.118"
  4. PingSet = " -n 1 -l 1 -w 500 "   
  5.     TheState = ws.run("ping.exe " & TheIP & PingSet ,0, True)
  6.     If TheState = 0 Then
  7.         MsgBox "aa服务器192.168.11.118网络通畅"
  8.     Else
  9.         MsgBox "aa服务器192.168.11.118网络不通畅"
  10.     End If

  11. TheIP = "10.10.128.13"
  12. PingSet = " -n 1 -l 1 -w 500 "   
  13.     TheState = ws.run("ping.exe " & TheIP & PingSet ,0, True)
  14.     If TheState = 0 Then
  15.         MsgBox "bb服务器10.10.128.13网络通畅"
  16.     Else
  17.         MsgBox "bb服务器10.10.128.13网络不通畅"
  18.     End If
复制代码
发表于 2015-12-22 13:40:43 | 显示全部楼层
能。那样的判断方式靠谱么?
 楼主| 发表于 2015-12-22 16:19:31 | 显示全部楼层

标题

回复 2# pcl_test
个人需求来说靠谱。如何修改VbS代码?
 楼主| 发表于 2015-12-22 21:13:42 | 显示全部楼层
MsgBox "bb服务器10.10.128.13网络通畅 & aa服务器192.168.11.118网络通畅"

MsgBox "bb服务器10.10.128.13网络不通畅 & aa服务器192.168.11.118网络不通畅"

MsgBox "bb服务器10.10.128.13网络通畅 & aa服务器192.168.11.118网络不通畅"

MsgBox "bb服务器10.10.128.13网络不通畅 & aa服务器192.168.11.118网络通畅"


总共有4个状态,如何修改vbs代码,实现智能判断?
 楼主| 发表于 2015-12-22 21:34:24 | 显示全部楼层
本帖最后由 ygqiang 于 2015-12-22 21:46 编辑

已经解决。
  1. '判断网络是否畅通,当大于500毫秒即判断为超时。
  2. Set ws = WScript.CreateObject("WScript.Shell")

  3. Fir=""
  4. Sec=""

  5. TheIP1 = "192.168.11.118"
  6. aaserv = "aa服务器"


  7. TheIP2 = "10.10.128.13"
  8. bbserv = "bb服务器"



  9. PingSet = " -n 1 -l 1 -w 500 "   
  10.     TheState = ws.run("ping.exe " & TheIP1 & PingSet ,0, True)
  11.     If TheState = 0 Then
  12.         Fir= aaserv & TheIP1 & "网络通畅"
  13.     Else
  14.         Fir= aaserv & TheIP1 & "网络不通畅"
  15.     End If


  16. PingSet = " -n 1 -l 1 -w 500 "   
  17.     TheState = ws.run("ping.exe " & TheIP2 & PingSet ,0, True)
  18.     If TheState = 0 Then
  19.         Sec= bbserv & TheIP2 & "网络通畅"
  20.     Else
  21.         Sec= bbserv & TheIP2 & "网络不通畅"
  22.     End If


  23. 'MsgBox Fir & vblf & Sec

  24. msg = CreateObject("wscript.shell").popup (Fir & vblf & Sec,"8")
  25. if msg = vbCancel then
  26.         wscript.quit   
  27. end if
复制代码
发表于 2015-12-23 00:51:40 | 显示全部楼层
发表于 2015-12-23 11:06:57 | 显示全部楼层
if ping("ping.com")<888 then xxxxxxxxxxxxx

  1. Function Ping(url) '检查网络Ping值,单位毫秒
  2.     Set objWMI = GetObject("winmgmts:\\.")
  3.     Set colPings = objWMI.ExecQuery ("Select * From Win32_PingStatus where Address = '" & url & "'")
  4.     Ping=9999
  5.     On error resume next
  6.         For Each objPing in colPings
  7.             Ping=objPing.ResponseTime+0
  8.         Next
  9.     On error goto 0
  10. End Function
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 09:01 , Processed in 0.019279 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表