i want to stop and restart some services remotly.
i can start one service , but could not find a way for starting more services once
this is my code for starting remotly a service. i think it,very simple, but i can not find more info on google
all the info ion internet is for start or stop only 1 services
my code:
Imports System.ServiceProcess
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim services() As ServiceController = ServiceController.GetServices("computer-name")
For Each service In services
If service.ServiceName = "W32Time" Then
If (service.Status = ServiceProcess.ServiceControllerStatus.Running) Then
MessageBox.Show("Servicesrunning")
Return
Else
MsgBox("service is starting")
service.Start()
End If
End If
Next
End Sub
End Class
i can start one service , but could not find a way for starting more services once
this is my code for starting remotly a service. i think it,very simple, but i can not find more info on google
all the info ion internet is for start or stop only 1 services
my code:
Imports System.ServiceProcess
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim services() As ServiceController = ServiceController.GetServices("computer-name")
For Each service In services
If service.ServiceName = "W32Time" Then
If (service.Status = ServiceProcess.ServiceControllerStatus.Running) Then
MessageBox.Show("Servicesrunning")
Return
Else
MsgBox("service is starting")
service.Start()
End If
End If
Next
End Sub
End Class