'参数 Dim WinScriptHost, Runtime, CheckThreeTime, startuppath, shortcut '后台运行bat Set WinScriptHost = CreateObject("WScript.Shell") WinScriptHost.Run Chr(34) & ".\z3_runservice.bat" & Chr(34), 0 '创建快捷方式,到‘启动’文件夹中 startuppath = WinScriptHost.SpecialFolders("Startup") Set shortcut = WinScriptHost.CreateShortcut(startuppath & "\z4_run_no_window.lnk") shortcut.TargetPath = WinScriptHost.CurrentDirectory & "\z4_run_no_window.vbs" shortcut.WindowStyle = 1 shortcut.WorkingDirectory = WinScriptHost.CurrentDirectory shortcut.Save '自定义弹窗方法 Sub PrintBox(text,boxtype,title,timeout) Dim WSH Set WSH = CreateObject("WScript.Shell") WSH.Popup text,timeout,title,boxtype Set WSH = Nothing End Sub '检测服务进程数量的方法 Function CheckServer() Dim reg,servercount,taskcountlist,task_list,task_str Set task_list = WinScriptHost.Exec("tasklist") Set reg = New RegExp reg.Global = True reg.MultiLine = True reg.Pattern = "^node.exe" task_str = task_list.Stdout.ReadAll Set taskcountlist = reg.Execute(task_str) servercount = 0 For Each tcl In taskcountlist servercount = servercount + 1 Next CheckServer = servercount End Function '判断进程是否存在,并弹窗提示运行是否成功 Runtime = 0 CheckThreeTime = 0 For i=1 To 30 Dim x x=CheckServer ' PrintBox "sever running count: " + CStr(x),64,"notice",6 if x=0 Then Runtime = 1 PrintBox "Start Plm Web Service Error !" + vbcrlf + "close in 6s",16,"error",6 Exit For Elseif x=2 Then if CheckThreeTime=3 Then Runtime = 1 PrintBox "Start Plm Web Service Success !" + vbcrlf + "close in 6s",64,"notice",6 Exit For Else CheckThreeTime = CheckThreeTime + 1 End if End if Next if Runtime = 0 Then PrintBox "Runtime Error !" + vbcrlf + vbcrlf + "close in 6s",16,"error",6 End if Set WinScriptHost = Nothing Set shortcut = Nothing