免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3546 | 回复: 2
打印 上一主题 下一主题

求windows脚本 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-03-26 09:37 |只看该作者 |倒序浏览
5可用积分
求windows脚本,此脚本大概功能如下:首先是一直ping某个IP,当ping这个IP连续10秒ping不通的时候,自动开启本机的IIS或者Apache服务   

    联系QQ-781624603     跪谢

论坛徽章:
0
2 [报告]
发表于 2010-03-26 21:54 |只看该作者
本帖最后由 emperor 于 2010-03-26 21:57 编辑
  1. '============================================================================
  2. '§ Script:        StartIIS.vbs
  3. '§ Purpose:       This script is used to start IIS after failed to ping an IP
  4. '§ Author:        Emperor (wharton)
  5. '§ Mail:         
  6. '§ Version:       v1.00 (2010.03.26)
  7. '§ History:       initialed on 2010.03.26                 
  8. '§ Usage:      
  9. '============================================================================

  10. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  11. Option Explicit

  12. Dim oShell     :Set oShell = CreateObject("WScript.Shell")

  13. '§ ========= Set Vars =============
  14. '§ ip=10.0.9.2
  15. '§ n=1, wtime=10000ms.
  16. '§ the 3 could be customize.
  17. Dim intPings:intPings = 1
  18. Dim intTO   :intTO = 10000
  19. Dim sIP     :sIP = "10.0.9.2"

  20. '§ =========
  21. Dim sCmd    :sCmd = "%comspec% /c ping.exe -n " & intPings & " -w " & intTO & " " & sIP
  22. Dim objPingOut :Set objPingOut =oShell.Exec(sCmd).StdOut
  23. If InStr(objPingOut.ReadAll,"TTL=")<>0 Then
  24.         oShell.popup "Pinged OK!",5,"Emperor ",0+64                             
  25. Else                                       
  26.   oShell.popup "Ping IP: "&sIP &" Failed, and IIS will be started in 5 minutes",5,"Emperor ",0+64
  27.   Dim iCmd   :iCmd = "%comspec% /c iisreset /start"
  28.   Dim sResult:sResult=oShell.Exec(iCmd).StdOut.ReadAll
  29.   MsgBox sResult                              
  30. End If     

  31. '§ ========= Release =============   

  32. Set oShell = Nothing
  33. Set objPingOut = Nothing
  34. Wscript.Quit         

  35. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~         
复制代码

论坛徽章:
0
3 [报告]
发表于 2010-04-08 08:44 |只看该作者
本帖最后由 aleng 于 2010-04-08 09:25 编辑

ping 10.10.10.5 -n 10 | Select-String "来自 10.10.10.5 的回复:" >null
if (!$?) {notepad}
------------win powershell 脚本 测试通过----------------
ping10次,只要返回一次“来自 10.10.10.5 的回复: ”即为真。
sc start iis 可以启动iis
想要一直运行这个脚本,可以用任务计划。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP