Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.
Public Function StopService(ByVal PC As String, ByVal Service As String) As Boolean Dim obj As ManagementObject Dim sc As ServiceController obj = New ManagementObject("\\" & PC & "\root\cimv2:Win32_Service.Name='" & Service & "'") ' Stop the service If obj("State").ToString = "Running" Then ' now start the service sc = New ServiceController(Service, PC) sc.Stop() sc.WaitForStatus(ServiceControllerStatus.Stopped) Return True Else Return False End If End Function
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.