我需要使用VBScript啓動多個服務。 我編寫了這個腳本來啓動服務,當我運行它時,它不會給出任何錯誤,並且不啓動服務。任何想法可能存在問題?VBScript啓動多個服務
sComputer = "."
aTargetSvcs= Array ("ServiceOne" &_
"ServiceTwo" &_
"ServiceThree" &_
"ServiceFour")
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 = "Stopped" Then
oService.StartService()
End If
End If
Next
Next
,因爲當你將服務名稱連接成一個字符串時,你知道如何編寫多行語句(提示:_),我懷疑你正在拉腿。 –
我真的很喜歡腳本和編程。經過一番研究後,我設法做到了。我會盡量使它分開。 – user3077069