I\'m getting this error when I try to start a windows service I\'ve created in C#:
My Code
In my case, I had to add 'Authenticated Users' in the list of 'Group or User Names' in the folder where the executable was installed.
I was getting this error because I misread the accepted answer from here: Create Windows service from executable.
sc.exe create <new_service_name> binPath= "<path_to_the_service_executable>"
For <path_to_service_executable>
, I was using the path of the executable's folder, e.g. C:\Folder
.
It needs to be the path of the executable, e.g. C:\Folder\Executable.exe
.
I also got the same error , It resolved by Right click on Service > Properties >Log On > log on as : Local System Account.
For me - the folder from which the service was to run, and the files in it, were encrypted using the Windows "Encrypt" option. Removing that and - voila!
In my case following was not checked.
Make sure the Path to executable
points to an actual executable (Right click service -> Properties -> General tab).
Via powershell (and sc.exe) you can install a service without pointing to an actual executable... ahem.