Home > Article > Backend Development > C# starts and stops Windows services
The practical functions provided by this API are often used to manage services in applications without having to go to the management services of the control panel. In the API provided by
ServiceController controller = new ServiceController(“e-M-POWER”); controller.Start(); if (controller.CanPauseAndContinue) { controller.Pause(); controller.Continue(); } controller.Stop();
.net, you can implement installation and uninstallation services in one sentence
if (args[0] == "/i") { ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location }); } else if (args[0] == "/u") { ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location }); }