Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot Start Windows Service in NetworkService account

I have a windows service project implementation that I am trying to install as network service.

process = new ServiceProcessInstaller();
process.Account = ServiceAccount.NetworkService;

however whenever I try to start the service I get :

System error 5 has occurred.

Access is denied.

This comes after running the net start MyService command in the visual studio command prompt which is running as administrator by the way.

Any help on how to get this to work? Thanks.

like image 343
Saher Ahwal Avatar asked Aug 15 '12 22:08

Saher Ahwal


People also ask

How do I give permission to restart a service?

In the Permissions for User or Group list, configure the permissions that you want for the user or group. When you add a new user or group, the Allow check box next to the Start, stop and pause permission is selected by default. This setting permits the user or group to start, stop, and pause the service.

What is Windows NetworkService?

The NetworkService account is a predefined local account used by the service control manager. This account is not recognized by the security subsystem, so you cannot specify its name in a call to the LookupAccountName function. It has minimum privileges on the local computer and acts as the computer on the network.


1 Answers

I would check that the Network Service account has permissions to execute. Steps to check:

  1. In Windows explorer go to the folder containing the binaries of the service
  2. Right-click on the folder > Properties > Security tab > Edit button
  3. Add > "NETWORK SERVICE" > OK
  4. Give it full control (just to test and then reduce permissions till it working)

screenshot

like image 77
oleksii Avatar answered Sep 28 '22 15:09

oleksii