z4_run_no_window.vbs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. '参数
  2. Dim WinScriptHost, Runtime, CheckThreeTime, startuppath, shortcut
  3. '后台运行bat
  4. Set WinScriptHost = CreateObject("WScript.Shell")
  5. WinScriptHost.Run Chr(34) & ".\z3_runservice.bat" & Chr(34), 0
  6. '创建快捷方式,到‘启动’文件夹中
  7. startuppath = WinScriptHost.SpecialFolders("Startup")
  8. Set shortcut = WinScriptHost.CreateShortcut(startuppath & "\z4_run_no_window.lnk")
  9. shortcut.TargetPath = WinScriptHost.CurrentDirectory & "\z4_run_no_window.vbs"
  10. shortcut.WindowStyle = 1
  11. shortcut.WorkingDirectory = WinScriptHost.CurrentDirectory
  12. shortcut.Save
  13. '自定义弹窗方法
  14. Sub PrintBox(text,boxtype,title,timeout)
  15. Dim WSH
  16. Set WSH = CreateObject("WScript.Shell")
  17. WSH.Popup text,timeout,title,boxtype
  18. Set WSH = Nothing
  19. End Sub
  20. '检测服务进程数量的方法
  21. Function CheckServer()
  22. Dim reg,servercount,taskcountlist,task_list,task_str
  23. Set task_list = WinScriptHost.Exec("tasklist")
  24. Set reg = New RegExp
  25. reg.Global = True
  26. reg.MultiLine = True
  27. reg.Pattern = "^node.exe"
  28. task_str = task_list.Stdout.ReadAll
  29. Set taskcountlist = reg.Execute(task_str)
  30. servercount = 0
  31. For Each tcl In taskcountlist
  32. servercount = servercount + 1
  33. Next
  34. CheckServer = servercount
  35. End Function
  36. '判断进程是否存在,并弹窗提示运行是否成功
  37. Runtime = 0
  38. CheckThreeTime = 0
  39. For i=1 To 30
  40. Dim x
  41. x=CheckServer
  42. ' PrintBox "sever running count: " + CStr(x),64,"notice",6
  43. if x=0 Then
  44. Runtime = 1
  45. PrintBox "Start Plm Web Service Error !" + vbcrlf + "close in 6s",16,"error",6
  46. Exit For
  47. Elseif x=2 Then
  48. if CheckThreeTime=3 Then
  49. Runtime = 1
  50. PrintBox "Start Plm Web Service Success !" + vbcrlf + "close in 6s",64,"notice",6
  51. Exit For
  52. Else
  53. CheckThreeTime = CheckThreeTime + 1
  54. End if
  55. End if
  56. Next
  57. if Runtime = 0 Then
  58. PrintBox "Runtime Error !" + vbcrlf + vbcrlf + "close in 6s",16,"error",6
  59. End if
  60. Set WinScriptHost = Nothing
  61. Set shortcut = Nothing