System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security

I got the same exception when trying to install a service from the command line when using installutil in Windows 7. The solution was to open the command line as Administrator and then run installutil.

Also you may find it easier to use a framework like TopShelf to host your services, because it manages all the setup configuration from the name and description of the service to how your recovery process will work. It also allows to easily start your service from inside the IDE when you are debugging it.


Run your command prompt as administrator. It will solve your problem


Run as Administrator

This is a very common issue that programmers are missing out


You are probably trying to install a service using

  1. A user account which does not have sufficient rights OR
  2. A user with Administrator privileges but did not run the Command Prompt in 'Administrator Mode'.

Specifically, the issue in this case is the creation of some EventLog registry keys during service install.

One way to fix this is to make sure that you are running the Command Prompt in Administrator mode. (Right-click > Run as Administrator)

I have also encountered some cases where this method still fails to solve the SecurityException problem due to some registry keys not having 'Full Control' permissions for Administrator accounts.

The following keys should have 'Full Control' set for Administrators in order for the service to be able to write to the EventLog:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application

This may be done by:

  1. Invoking the Windows Registry Editor
    • Run [Win + R]
    • Type 'regedit'
    • OK
  2. Navigate to a path listed above
  3. Right click on the desired path
  4. Make sure that both Read and Full Control permission checkboxes are ticked for Administrators
  5. Click Apply and OK
  6. Repeat the same process for the other path