Error 5 : Access Denied when starting windows service

前端 未结 30 2369
滥情空心
滥情空心 2020-12-04 18:49

I\'m getting this error when I try to start a windows service I\'ve created in C#:

\"alt

My Code

相关标签:
30条回答
  • 2020-12-04 19:16

    I accidentally set my service to run as Local service solution was to switch to Local System

    0 讨论(0)
  • 2020-12-04 19:18

    If you are getting this error on a server machine try give access to the folder you got the real windows service exe. You should go to the security tab and select the Local Service as user and should give full access. You should do the same for the exe too.

    0 讨论(0)
  • 2020-12-04 19:19

    I realize this post is old, but there's no marked solution and I just wanted to throw in how I resolved this.

    The first Error 5: Access Denied error was resolved by giving permissions to the output directory to the NETWORK SERVICE account.

    The second Started and then stopped error seems to be a generic message when something faulted the service. Check the Event Viewer (specifically the 'Windows Logs > Application') for the real error message.

    In my case, it was a bad service configuration setting in app.config.

    0 讨论(0)
  • 2020-12-04 19:19

    One of the causes for this error is insufficient permissions (Authenticated Users) in your local folder. To give permission for 'Authenticated Users' Open the security tab in properties of your folder, Edit and Add 'Authenticated Users' group and Apply changes.

    Once this was done I was able to run services even through network service account (before this I was only able to run with Local system account).

    0 讨论(0)
  • 2020-12-04 19:20

    Right click on the service in service.msc and select property.

    You will see a folder path under Path to executable like C:\Users\Me\Desktop\project\Tor\Tor\tor.exe

    Navigate to C:\Users\Me\Desktop\project\Tor and right click on Tor.

    Select property, security, edit and then add. In the text field enter LOCAL SERVICE, click ok and then check the box FULL CONTROL

    Click on add again then enter NETWORK SERVICE, click ok, check the box FULL CONTROL

    Then click ok (at the bottom)

    0 讨论(0)
  • 2020-12-04 19:21

    Use LocalSystem Account instead of LocalService Account in Service Installer.

    You can do this either from doing below change in design view of your service installer:
    Properties of Service Process Installer -> Set Account to LocalSystem.

    or by doing below change in in designer.cs file of your service installer:

    this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
    
    0 讨论(0)
提交回复
热议问题