要做一个监控tomcat是否运行的服务,用vb开发。当监控到tomact未运行时,就运行tomcat下的startup.bat文件启动tomcat服务;但是执行以下代码,都未能启动tomcat服务,请教如何处理?    Shell ("cmd.exe  /c D:\apache-tomcat-6.0.29\bin\startup.bat")    ShellExecute 1, "open ", "D:\apache-tomcat-6.0.29\bin\startup.bat", vbNullString, vbNullString, vbNull

解决方案 »

  1.   

    Shell "cmd.exe /c D:\apache-tomcat-6.0.29\bin\startup.bat"

    aa=Shell ("cmd.exe /c D:\apache-tomcat-6.0.29\bin\startup.bat")
      

  2.   

    执行之后,还是未能启动tomcat。
    继续请教?
      

  3.   

    本帖最后由 bcrun 于 2010-12-31 22:29:27 编辑
      

  4.   

    double click the file "D:\apache-tomcat-6.0.29\bin\startup.bat" ?
      

  5.   

    try the code below:
    ShellExecute 1, "open ", "D:\apache-tomcat-6.0.29\bin\startup.bat", vbNullString, "D:\apache-tomcat-6.0.29\bin\", vbNull
      

  6.   

    shell D:\apache-tomcat-6.0.29\bin\startup.bat[code=BatchFile]set servicename=tomcat
    (sc start %servicename%|findstr "[SC] StartService FAILED 1056:")&&echo 服务已经启动||ehco 服务启动失败[/code]
    要启动服务只需Start,不用检测服务是否已经启动,也不会出错
      

  7.   

    那直接shell "net stop tomcat"就行了。
      

  8.   

    startup.bat 里面的内容是什么?贴出来就知道为什么了
      

  9.   

    startup.bat是apache-tomcat-6.0.29下的启动服务的批处理文件。现在直接执行以下语句,就可正常启动tomcat服务,之前不可以。
    Shell "D:\apache-tomcat-6.0.29\bin\startup.bat"谢谢各位关注