简体   繁体   English

系统启动时如何使Windows服务变为“正在运行”

[英]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.

相关问题 Windows 启动时运行程序(登录前) - Running a program when Windows Boots (before Login) 在带有“本地系统帐户”的“ Windows服务”下运行时,.NET Windows 7截屏不起作用 - .NET Windows 7 take screenshot not working when running under 'Windows Service' with 'Local System Account' 我如何检测 windows 何时启动并使用.Net / C# 捕获它? - How can i detect when windows boots up and capture it using .Net / C#? 运行Windows服务时出现FileNotFoundException - FileNotFoundException when running a Windows Service 如何获取以用户身份运行的Windows 7应用程序的MainWindowHandle <foo> 从作为本地系统运行的服务中? - How can I get the MainWindowHandle of a Windows 7 application running as user <foo> from within a service running as Local System? 当系统处于睡眠状态时,Windows服务中的计时器如何表现? - How do timers in a windows service behave when the system is asleep? 如何让Windows服务有效地等待RabbitMQ可用 - How to have a Windows Service wait efficiently for RabbitMQ to become available 手机启动时运行 android Worker 不起作用 - Running an android Worker when phone boots doesn't work 运行任务时如何在 Windows 服务中捕获异常? - How do I capture an exception in a windows service when running a Task? System.NullReferenceException for .NET 服务在 Windows Server IIS 上运行,但在 Visual Studio IIS Express 中运行时在本地工作 - System.NullReferenceException for .NET service running on windows server IIS but works locally when running in Visual Studio IIS Express
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM