蛋糕的心情写的
- ' Start service
- Sub startSvc(lists)
- list=split(lists, ",")
- For i=0 To UBound(list)
- Set objWMIService = GetObject("winmgmts:\\")
- Set colServiceList = objWMIService.ExecQuery("select * from Win32_Service where Name = '" & list(i) & "'")
- For Each objService in colServiceList
- If objService.State <> "Running" Then
- If objService.StartMode = "Disabled" Then
- objService.ChangeStartMode("Automatic") 'Automatic|Manual|Disabled
- End If
- errReturnCode = objService.StartService()
- End If
- Next
- Set objWMIService=Nothing
- Next
- End Sub
复制代码
用法:startSvc("这里是要开始的服务名称") |