Home > Backend Development > C#.Net Tutorial > C# starts and stops Windows services

C# starts and stops Windows services

大家讲道理
Release: 2016-11-10 10:13:49
Original
1572 people have browsed it

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();
Copy after login

.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 });
 }
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template