.NET Framework provides System.ServiceProcess namespace that contains classes developers can use to create and install Windows Services. These classes include ServiceBase, ServiceInstaller and ServiceProcessInstaller. This namespace also contains one class which can display the list of all the Windows Services running on local or remote computer. In this tutorial I will show you how you can display the list of locally running Windows Services in VB.NET.
You can write following code at Form load even to populate listbox control with all locally running Windows Services. You need to import System.ServiceProcess namespace for the code example below.
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim localServices As ServiceController() = ServiceController.GetServices()
For Each service As ServiceController In localServices
listBox1.Items.Add(service.DisplayName)
Next
End Sub
Write following code at listbox SelectedIndexChanged Event to get information about currently selected Windows Service.
Private Sub listBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim localServices As ServiceController() = ServiceController.GetServices()
Dim service As ServiceController = localServices(listBox1.SelectedIndex)
label4.Text = service.DisplayName
label5.Text = service.ServiceName
label6.Text = service.Status.ToString()
End Sub
please how can i start or restart or stop Services on my computer by app vb.net
and how i can do it for remote computer
thanks
Great Tutorial Thank you for your time and help very well presented. 5*
Thanks for the great information. I was actually searching for a source code in VB.NET that helps me not only list the Windows Services but also manage them (i.e. enable, disable), etc.
By the way, nice article and keep it up!
Thank you very much i helped me this is what i needed it 😉
I need to start a particular services from the Database can u provide a sample
sir,
i Create a Windows service in vb.net .by using the system i insert the time value for every one Milli Second
after restart of the System the time Doesn’t inserted on the database ,what is the Problem