问题
The error:
I get a popup window when trying to manually start the windows service. It says:
Windows could not start the XXX service on Local Computer. Error: 1069: The service did not start due to a logon failure.
Post-build events:
There are 2 Windows services in the solution and they have the same post-build events:
REM C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /u "$(TargetPath)"
REM C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /i /username=.\administrator /password=blabla "$(TargetPath)"
But for some reason it's only the first service that is installed during debug-build mode. The other is not (despite similar post-build events). So I manually used the InstallUtil with the administrator login and blabla password from the post-build events. That did install it, but one is installed with "Log On As = Local System" (works!) and the other has "Log On As = .\administrator" (does not work!).
I guess that's what triggers the error. Why the difference? Is there another install going on the solution build somewhere? It should be said that it is a solution consisting of 47 projects.
回答1:
I'm 99% sure that you can solve this by granting the Log on as service privilege to the administrator user.
来源:https://stackoverflow.com/questions/5230353/trying-to-start-a-new-service-but-having-a-permission-problem