user-0 提问: windows服务的自启动问题--初学者提问

回复:
user: user-0
content: 谢谢大家关注此问题。  经过我的调试，果然是系统的一个软件给阻止了服务自启动。这个服务自启动的程序代码本身没有问题。  再次谢谢大家关注此问题。  结贴给分。

user: user-1
content: 贴全代码看看。

user: user-2
content: 引用 7 楼 truexf 的回复:被360阻止了无疑 卸载360后再试试。

user: user-3
content: 被360阻止了无疑

user: user-0
content: 引用 4 楼 zhao4zhong1 的回复:先试试手动启动服务看能不能成功，如果能，请参考以下“杀手锏”： 用调试器(OD,WINDBG等)调试服务程序 To debug the initialization code of a service application, the debugger must be attached when the service is started. This is accomplished by creating a registry key:  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\ProgramName   The ProgramName is the image file for the service application you are debugging. Do not specify a path. For example, the ProgramName might look like MyService.exe.  Under this key create a string data value called Debugger. The value of this string should be set to the full path of the debugger that will be used. For example,  c:\Debuggers\windbg.exe    In addition to setting this registry key, the service application must be marked as "interactive". This allows your service to interact with the desktop, and allows the debugger window to appear on your desktop.  This again requires modifying a registry key: you must bitwise-or the type entry for your service with 0x100 (this is the value for SERVICE_INTERACTIVE_PROCESS according to Winnt.h). The exact location and name of this registry entry varies. For example:  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyServiceKey   Finally, you need to adjust the service application timeout. Otherwise, the service application will kill the debugger within 20 seconds after starting. Adjusting the timeout involves setting an entry in the following registry key:  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control   Under this key, create a DWORD data value called ServicesPipeTimeout. Set this entry to the amount of time in milliseconds that you want the service to wait before timing out. For example, 60,000 is one minute, while 86,400,000 is 24 hours.  设置ServicesPipeTimeout后需要重启系统才生效  Now, when the service is started, the debugger will also start. When the debugger starts, it will stop at the initial process breakpoint, before the service has begun running. This allows you to set breakpoints or otherwise configure your debugging session to let you monitor the startup of your service. Another option is to place calls to the DebugBreak function in your service from the point at which you would like to break into the debugger. (For more information, see DebugBreak in the Platform SDK documentation.)  If your service is running with other services in a Service Host Process, you may need to isolate the service into its own Service Host Process.   服务可以手动启动后，正常运行，一切ok。就是开机不自启动，手动启动后，一切正常。 我先试试这个杀手锏。 谢谢。

user: user-2
content: 提醒： 用depends.exe查看exe依赖的dll

user: user-2
content: 先试试手动启动服务看能不能成功，如果能，请参考以下“杀手锏”： 用调试器(OD,WINDBG等)调试服务程序 To debug the initialization code of a service application, the debugger must be attached when the service is started. This is accomplished by creating a registry key:  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\ProgramName   The ProgramName is the image file for the service application you are debugging. Do not specify a path. For example, the ProgramName might look like MyService.exe.  Under this key create a string data value called Debugger. The value of this string should be set to the full path of the debugger that will be used. For example,  c:\Debuggers\windbg.exe    In addition to setting this registry key, the service application must be marked as "interactive". This allows your service to interact with the desktop, and allows the debugger window to appear on your desktop.  This again requires modifying a registry key: you must bitwise-or the type entry for your service with 0x100 (this is the value for SERVICE_INTERACTIVE_PROCESS according to Winnt.h). The exact location and name of this registry entry varies. For example:  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyServiceKey   Finally, you need to adjust the service application timeout. Otherwise, the service application will kill the debugger within 20 seconds after starting. Adjusting the timeout involves setting an entry in the following registry key:  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control   Under this key, create a DWORD data value called ServicesPipeTimeout. Set this entry to the amount of time in milliseconds that you want the service to wait before timing out. For example, 60,000 is one minute, while 86,400,000 is 24 hours.  设置ServicesPipeTimeout后需要重启系统才生效  Now, when the service is started, the debugger will also start. When the debugger starts, it will stop at the initial process breakpoint, before the service has begun running. This allows you to set breakpoints or otherwise configure your debugging session to let you monitor the startup of your service. Another option is to place calls to the DebugBreak function in your service from the point at which you would like to break into the debugger. (For more information, see DebugBreak in the Platform SDK documentation.)  If your service is running with other services in a Service Host Process, you may need to isolate the service into its own Service Host Process.

user: user-0
content: 引用 2 楼 zhao4zhong1 的回复:估计是权限问题或被防火墙或杀毒软件屏蔽了。 注意服务的登录身份。  我用的系统管理员administrator注册的服务，权限应该够用了，防火墙我是关闭的，杀毒软件是360，这个应该没有关系吧？

user: user-2
content: 估计是权限问题或被防火墙或杀毒软件屏蔽了。 注意服务的登录身份。

user: user-0
content: 各位高手，咋没有人指点我一下呢？！！