Hi, i've been doing research about this for a while now. I'm pretty sure it's correct, but the console.writeline is not providing any messeges when program is executed. Im using Visual Studio 2010 pro. Is there anything im missing or doing wrong? Here's
what i have:
Private Sub CheckServiceButton_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckServiceButton.Click
' This will check if the service is running '
Dim sc As New ServiceProcess.ServiceController()
sc.ServiceName = "Themes"
MessageBox.Show("The Themes service status is currently set to Running")
If sc.Status = ServiceProcess.ServiceControllerStatus.Running Then
' Start the service if the current status is stopped '
Console.WriteLine("Starting the Themes service")
Try
' Start the service, and wait until its status if "Running".
sc.Start()
sc.WaitForStatus(ServiceProcess.ServiceControllerStatus.Running)
' Display the current service status '
Console.WriteLine("The Themes service status is now set to {0},", sc.Status)
Catch ex As Exception
Console.WriteLine("Could not start the Themes service.")
Console.ReadLine()
End Try
End If
End Sub
Thanks.