天天看点

vb语言脚本自动启动Tomcat

下面我写一段vbs脚本,把它保存成文件(后缀名为vbs)后双击运行就行了

on   error   resume   Next   

  Dim   a   

  a   =   True   

  set   WshShell   =   WScript.CreateObject("WScript.Shell")   

  Do   While   a   

  set   http   =   CreateObject("Microsoft.XMLHTTP")   

  http.open   "POST","http://192.168.80.144:8080",false   

  http.send   

 if   http.Status   >   500  then      

  WshShell.Run("net   start   tomcat6")   

  end   if   

  WScript.Sleep(30000)   

  loop

 回钦波讲解:http://192.168.80.144:8080 换成你想要的ip地址

                     http.Status 会返回不同的状态,如返回200是OK,404是服务器报错,这里500是没有开启

                                       服 务

                      net   start   tomcat6   ,当本机安装tomcat6时 保持作者写法不变即可,如果是tomcat5改为

                                                           net start tomcat5 即可

                       WScript.Sleep(30000)   , 休息30秒