[英]How to make Windows service become “Running” when the system boots
I know this has been answered here but I'm having a more specific issue. 我知道这里已经回答了这个问题,但是我有一个更具体的问题。 I did what was suggested by adding
我做了建议的添加
serviceInstaller1.StartType = ServiceStartMode.Automatic;
serviceInstaller1.DelayedAutoStart = true;
and indeed I can confirm that after installing I see my service has Startup Type
equal to Automatic (Delayed Start)
. 并且确实可以确认安装后,我看到我的服务的
Startup Type
等于Automatic (Delayed Start)
。 However I restarted my machine and it doesn't have Status
equal to Running
like other services. 但是,我重新启动了计算机,它的
Status
不像其他服务一样正在Running
。 I tried without serviceInstaller1.DelayedAutoStart = true;
我尝试不使用
serviceInstaller1.DelayedAutoStart = true;
and same issue. 和同样的问题。 I'm wondering if my
Log On As
needs to be something other than my domain account. 我想知道我的“
Log On As
身份”是否需要使用域帐户以外的其他名称。 Or what else could be the issue? 还是其他问题?
First, I would check if the service starts with logon = SYSTEM. 首先,我将检查服务是否以登录= SYSTEM开头。 If that works, in my experience (big enterprise environment), the most common reason is that the user account under which the service is supposed to run does not have the privilege "logon as service".
如果这有效,以我的经验(大型企业环境),最常见的原因是应该运行服务的用户帐户没有“作为服务登录”特权。 Look in the Windows security event log for logon errors.
在Windows安全事件日志中查找登录错误。 Depending on your environment you can use use a GPO for enabling this privilege or may set it yourself (via local security policy) if it is allowed in your Windows environment.
根据您的环境,您可以使用GPO来启用此特权,或者可以在Windows环境中允许的情况下通过本地安全策略自行设置(通过本地安全策略)。
Or perhaps your service crashes in OnStart(), but this can also (as Brien and Shetty suppose) normally seen in the event log (application event log). 也许您的服务在OnStart()中崩溃,但这也可以(如Brien和Shetty所假定的那样)在事件日志(应用程序事件日志)中正常显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.