Programmatically Start/Stop Windows Service

Source: http://www.dotnetspider.com/resources/865-How-start-stop-windows-services-programmati.aspx

[C#]

using System.ServiceProcess; // add .Net Reference to Project

ServiceController controller = new ServiceController();

controller.MachineName = ".";
controller.ServiceName = "MySQL";
string status = controller.Status.ToString();

// Stop the service
controller.Stop();

// Start the service
controller.Start();

Comments

Popular posts from this blog

Get Images Bookmarklet

iFrame Opera Extension (Updated for Opera 39)

Nomor Telepon PSTN (Pulsa Lokal) Call Center Bank-Bank di Indonesia