如何在Windows快速启动时从服务程序执行功能

时间:2022-05-10 20:52:10

How can I execute a function from service program when Windows 10 Fast Startup. Here is My scenario:

如何在Windows 10 Fast Startup中从服务程序执行功能。这是我的场景:

I have windows service program to start some of the exe/function during windows startup.

我有Windows服务程序在Windows启动期间启动一些exe / function。

It works fine in other windows version except windows 10 fast startup.

除了Windows 10快速启动之外,它在其他Windows版本中工作正常。

I have used SERVICE_CONTROL_STOP, SERVICE_CONTROL_SHUTDOWN, SERVICE_CONTROL_PAUSE and SERVICE_CONTROL_CONTINUE in ServiceMain function, but ServiceMain is not called during fast startup.

我在ServiceMain函数中使用了SERVICE_CONTROL_STOP,SERVICE_CONTROL_SHUTDOWN,SERVICE_CONTROL_PAUSE和SERVICE_CONTROL_CONTINUE,但在快速启动期间未调用ServiceMain。

If I manually start/stop/pause/continue the service, its working.

如果我手动启动/停止/暂停/继续服务,它的工作。

Is there any way to create/start a service with service handler for windows fast startup?

有没有办法用Windows快速启动服务处理程序创建/启动服务?

1 个解决方案

#1


0  

For fast startup,windows terminates user sessions and hibernates session 0 (which contains kernel,drivers,services,etc) when you shutdown and continues run after fast startup.So,the service can't detect shutdown because it has never been stopped or suspended.Unless,you register some notifications or handle session changes.

对于快速启动,Windows会在您关闭时终止用户会话并休眠会话0(其中包含内核,驱动程序,服务等),并在快速启动后继续运行。因此,该服务无法检测到关闭,因为它从未被停止或暂停。除非您注册了一些通知或处理会话更改。

So you can handle SERVICE_ACCEPT_SESSIONCHANGE control code to do what you want.

因此,您可以处理SERVICE_ACCEPT_SESSIONCHANGE控制代码以执行您想要的操作。

For short,check this link

简而言之,请查看此链接

#1


0  

For fast startup,windows terminates user sessions and hibernates session 0 (which contains kernel,drivers,services,etc) when you shutdown and continues run after fast startup.So,the service can't detect shutdown because it has never been stopped or suspended.Unless,you register some notifications or handle session changes.

对于快速启动,Windows会在您关闭时终止用户会话并休眠会话0(其中包含内核,驱动程序,服务等),并在快速启动后继续运行。因此,该服务无法检测到关闭,因为它从未被停止或暂停。除非您注册了一些通知或处理会话更改。

So you can handle SERVICE_ACCEPT_SESSIONCHANGE control code to do what you want.

因此,您可以处理SERVICE_ACCEPT_SESSIONCHANGE控制代码以执行您想要的操作。

For short,check this link

简而言之,请查看此链接