Public Sub StopService(strServiceName As String)
Dim objWMIService As Object
Dim colProcesses As Object
Dim objProcess, s
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Service Where Name ='" & strServiceName & "'")
For Each objProcess In colProcesses
s = objProcess.StopService()
Next
Set objWMIService = Nothing
Set colProcesses = Nothing
Set objProcess = Nothing
End Sub
Public Sub StartService(strServiceName As String)
Dim objWMIService As Object
Dim colProcesses As Object
Dim objProcess, s
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Service Where Name ='" & strServiceName & "'")
For Each objProcess In colProcesses
s = objProcess.StartService()
Next
Set objWMIService = Nothing
Set colProcesses = Nothing
Set objProcess = Nothing
End Sub
Start Stop Service VB6 Code
Code:
0 comments:
Post a Comment