System error 5 Access denied when starting the .NET service

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

System error 5 has occurred. Access is denied. 

I run the command line with elevated privileges, so this is not a problem. Is there a place where I can see what error is occurring.

+46
windows visual-studio error-handling windows-services
Feb 22 '09 at 5:37
source share
10 answers

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

The local service account did not have permissions on the output .exe file, and that is why an error occurred.

+48
Feb 22 '09 at 5:58
source share

There was the same problem.

Fixed by starting the service in the "Local system account" section

enter image description here

+15
Sep 16 '13 at 10:55 on
source share

In my case, the solution was even so simple: run the command line as an administrator.

+11
Sep 03 '12 at 11:24
source share

I see that you fixed the problem; but in fact you, as a rule, should not start the service from the bin folder of the project - the files should be placed somewhere regardless of the project and profile (for example, in program files). For debugging purposes (when it will be located in the bin folder), you can determine if this is a service in Main() , and if it runs interactively, just run the service code directly, rather than the usual service launch setup.

You can detect either by adding a command line argument, or you can try checking Environment.UserInteractive .

+9
Feb 22 '09 at 9:23
source share

The Local Services account does not seem to have privileges to manage the service. Thus, in the LogOn Property service, change the account type to the local system and allow the service to interact with the desktop.

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

Finally, when you want to start a service from the command line using the "net start [service name]" command, you must start the command line as an administrator.

+2
Dec 27 '14 at 6:59
source share

I had the same problem because my project and its source code were in a folder with the NTFS Encrypting File System (

+1
Jan 28 '10 at 7:07
source share

I had the same problem when I migrated the service from vs05 to vs2010, starting from frame 2.0 to version 4.0. I was denied access. As soon as the switch to framework 2.0 worked again. %?% #% &% & the problem was that the initialization string for the service was incorrect (?!). A string of expected quotes at the beginning and at the end!

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

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

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

0
Oct. 16 '13 at 6:32
source share

Run it from the Task Scheduler with the highest privileges, and it will work.

0
Mar 04 '16 at 18:05
source share

A user account with administrator rights will prompt: "Are you sure?" In situations where an administrator account is not requested. I had this problem with net stop netprofm.

To delete a query, do this.

Control Panel, User Accounts, Changing User Account Control Settings, Never Notify

It seems that the user account with administrator privileges has the same behavior as the administrator account.

0
Mar 07 '16 at 16:42
source share

Just ran into this problem after I ran "sc config" to change the binPath services.

The only fix that worked for me was to "sc uninstall" the service and install it again.

After that, everything worked perfectly.

0
Apr 23 '17 at 22:33
source share



All Articles