Add a reference to the System.ServiceProcess namespace, by going to Project > Add Reference.. and selecting it from the list in the .NET tab.Here u toggle Adobe Version Cue CS3 service
Imports System.ServiceProcess
Function ToggleProcess(ByVal strServiceName As String) As Boolean
Dim service As New ServiceController(strServiceName)
Select Case service.Status
Case ServiceControllerStatus.Stopped
service.Start()
Case ServiceControllerStatus.Running
service.Stop()
Case Else
service.Dispose()
Return False
End Select
service.Dispose()
Return True
End Function
' Example Usage
Try
ToggleProcess("Adobe Version Cue CS3")
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try