title: Windows could not start the [service name] service on Local Computer. Error 5: Access is Denied
body: <p>I know many of you guys will think this problem is a duplicate and already solve before, 
  but I having trouble in this problem and I am really frustrated right now because I can't solve this.</p>
  
  <p>This is the first time I work with Windows Service, I wanted to Install my Service programmatically and I came up with this solution:</p>
  
  <pre><code>ServiceProcessInstaller ProcesServiceInstaller = new ServiceProcessInstaller();
  ProcesServiceInstaller.Account = ServiceAccount.LocalSystem;
  /**
      I already try to used this
      ProcesServiceInstaller.Account = ServiceAccount.LocalService;
      ProcesServiceInstaller.Username = null;
      ProcesServiceInstaller.Password = null;
  **/
  ServiceInstaller ServiceInstallerObj = new ServiceInstaller();
  InstallContext Context = new System.Configuration.Install.InstallContext();
  String path = String.Format("/assemblypath={0}", @"" + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location));
  String[] cmdline = { path };
  
  Context = new System.Configuration.Install.InstallContext("Service-Install.log", cmdline);
  ServiceInstallerObj.Context = Context;
  ServiceInstallerObj.DisplayName = serviceName;
  ServiceInstallerObj.Description = "Sample Description";
  ServiceInstallerObj.ServiceName = serviceName;
  ServiceInstallerObj.StartType = ServiceStartMode.Automatic;
  ServiceInstallerObj.Parent = ProcesServiceInstaller;
  
  System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
  ServiceInstallerObj.Install(state); 
  </code></pre>
  
  <p>the above code is working and I can see it in my <code>Services</code>.
  but everytime I right click on it and try to Start the Service I get this error:</p>
  
  <pre><code>Windows could not start the [service name] service on Local Computer.
  Error 5: Access is Denied.
  </code></pre>
  
  <p>I search for solution but none of this are working:</p>
  
  <p>First I configure my manifest with this:</p>
  
  <p><code>&lt;requestedExecutionLevel level="requireAdministrator" uiAccess="false" /&gt;</code></p>
  
  <p>Second this link: <a href="https://stackoverflow.com/questions/4267051/error-5-access-denied-when-starting-windows-service">Link1</a> and <a href="https://stackoverflow.com/questions/20468524/windows-could-not-start-service-on-local-computer-error-5-access-is-denied">Link2</a></p>
  
  <p>by doing the below</p>
  
  <pre><code>*Right-click on top-level folder containing the service executable. Go to Properties
  *Go to "Security" Tab
  *Click "EDIT"
  *Click "ADD"
  *Enter the name "SYSTEM","NETWORK SERVICE", "SERVICE" click OK (I already add this 3 account)
  *Highlight "SYSTEM","NETWORK SERVICE", "SERVICE" user, and click ALLOW check-box next to "Full control"
  *Click OK twice
  </code></pre>
  
  <p>and nothing is working.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The below image is the Security Permission I added.
  <a href="https://i.stack.imgur.com/aAUGU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aAUGU.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/4SHOY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4SHOY.png" alt="enter image description here"></a></p>
  
  <p>and I already allow all the checkboxes*(Except the Deny)* specially the full control.</p>
  
  <p>and the below image is what I have in Windows Event Viewer.
  <a href="https://i.stack.imgur.com/5uRHt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5uRHt.png" alt="enter image description here"></a></p>
  
  <p>and the Error is Access Denied
  <a href="https://i.stack.imgur.com/gWMCG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gWMCG.png" alt="enter image description here"></a></p>
  
  <p>anyone please can help me? Thank you!</p>