System error 5 Access is denied when starting a .NET service

前端 未结 10 1696
离开以前
离开以前 2020-12-03 02:32

When I try to start a service I created in Visual Studio I receive the following error:

System error 5 has occurred.

Access is denied.

I a

相关标签:
10条回答
  • 2020-12-03 02:56

    I had the same problem when I migrated a service from vs05 to vs2010, from framework 2.0 till framework 4.0 at the same time. I got Access denied. As soon as a change back to framework 2.0 it worked again. The ?%¤#%&%& problem was that the initializing string for the service was incorrect (?!). The string expected quotes at the beginning and at the end!

    Before....path + service name" "/parameter=1 ' this had worked with framework 2.0

    After...."path + service name" "/parameter=1"

    Access Denied has nothing to do with the problem. Why not "Path not found " or "missing parameter"

    0 讨论(0)
  • 2020-12-03 03:08

    The Local Services account doesn't seem to be privileged to control a service. So, in the service's LogOn Property, change the account type to Local System and allow service to interact with desktop.

    Also, make sure that, you install the service using instalutil, as an administrator.

    Lastly, when you want to run a service from the command prompt using the "net start [service name]" command, you have to run the command prompt as an administrator.

    0 讨论(0)
  • 2020-12-03 03:09

    To get it to work I needed to add permissions to the output bin\debug folder for my service project.

    The Local Service account didn't have permissions to the output .exe file, and this was why the error was occuring.

    0 讨论(0)
  • 2020-12-03 03:09

    In my case the solution was even that simple: Run Command Prompt as administrator.

    0 讨论(0)
提交回复
热议问题