0
sComputer = "."
Set Runninglist = CreateObject("System.Collections.ArrayList")
aTargetSvcs= Array ("pageserver","CacheServer","CrystalAPS","CrystalInputFileServer","CrystalOutputFileServer","CrystalReportApplicationServer", "JobServer_Report")
Set oWMIService = GetObject("winmgmts:" & "{impersonationlevel=impersonate}!\\" _
& sComputer & "\root\cimv2")
Set cServices = oWMIService.ExecQuery("SELECT * FROM Win32_Service")
For Each oService In cServices
For Each sTargetSvc In aTargetSvcs
If LCase(oService.Name) = LCase(sTargetSvc) Then
If oService.State <> "Started" Then
Runninglist.Add oService.Name
oService.StopService()
End If
End if
Next
Next
WScript.Sleep 3000
For Each oService In cServices
For Each sTargetSvc In Runninglist
If LCase(oService.Name) = LCase(sTargetSvc) Then
oService.StartService()
End If
Next
Next
目標:我想在這個以開始從Runninglist服務,只有當他們先前已停止:
CrystalAPS
晶振輸入文件資源庫服務器
水晶輸出文件資源庫服務器
水晶報表應用程序服務器
水晶報表作業服務器
水晶緩存服務器
Crystal頁服務器啓動/停止服務在特定的順序只有當以前運行
爲什麼不簡單定義這些服務之間的依賴關係? –