The meaning of what. I create an absolutely empty service:
projectinstaller.cs
using System; using System.ComponentModel; using System.Configuration.Install; using System.ServiceProcess; namespace mrserivce { [RunInstaller(true)] public class ProjectInstaller : Installer { private ServiceProcessInstaller serviceProcessInstaller; private ServiceInstaller serviceInstaller; public ProjectInstaller() { serviceProcessInstaller = new ServiceProcessInstaller(); serviceInstaller = new ServiceInstaller(); serviceProcessInstaller.Account = ServiceAccount.LocalService; serviceInstaller.ServiceName = MainService.MyServiceName; this.Installers.AddRange(new Installer[] { serviceProcessInstaller, serviceInstaller }); } } } mainservice.cs
using System; using System.ServiceProcess; namespace mrserivce { public class MainService : ServiceBase { public const string MyServiceName = "mrserivce"; public MainService() { InitializeComponent(); } private void InitializeComponent() { this.ServiceName = MyServiceName; } protected override void OnStart(string[] args) { } protected override void OnStop() { } } } kernel.cs
using System; using System.ServiceProcess; namespace mrserivce { static class Kernel { static void Main() { ServiceBase.Run(new ServiceBase[] { new MainService() }); } } } Next, I compile it in Release, open cmd from the admin, use cd to go to the directory with the executable, and write:
sc create testService binPath=mrservice.exe type=own start=auto sc start testService After that (instantly) an error occurs:
[SC] StartService: ошибка: 1053: Служба не ответила на запрос своевременно. What is the problem?
sc.exedoes not use it - Pavel Mayorov