Note that there are some explanatory texts on larger screens.

plurals
  1. POStarting a service programatically
    text
    copied!<p>He folks, I'm struggeling with starting a service from another application.</p> <p>Ok, first, thats my starting point: I got a usual service wrapped into my own class which inherits from ServiceBase. Furthermore I got a ProjectInstaller instance, which inherits from System.Configuration.Install.Installer and takes care of installing my service on the system in the right way. </p> <p>it's got these parameters:</p> <pre><code>serviceInstaller1.ServiceName = "NameOfService"; serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Manual; serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService; </code></pre> <p>This ProjectInstaller output is installed through a usual C# .NET installation project.</p> <p>The service is shown in the GUI list of services within system control -> administration -> services. But what I'm wondering about is that the service does not appear in the list of services, if I use the cmd.exe and type "net start". </p> <p>That's waht I have so far. Now I want to start my service from another application. This application inherits from </p> <pre><code>ServiceController </code></pre> <p>If I want to call now the </p> <pre><code>Start() </code></pre> <p>method, I get an error telling me that the service could not be opened of the local machine.</p> <p>I use the same Service Name as stated above. T'm confused about that, because I thought the service is installed correctly through my installer. Or does my application (and the cmd.exe too) does not have enough rights to access the service?</p> <p>If anybody has an idea, feel free to tell me :) Thanks in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload