简体   繁体   English

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

[英]How can I Execute a Function from service program when Windows Fast Startup

How can I execute a function from service program when Windows 10 Fast Startup. Windows 10快速启动时如何从服务程序执行功能。 Here is My scenario: 这是我的情况:

I have windows service program to start some of the exe/function during windows startup. 我有Windows服务程序,用于在Windows启动过程中启动某些exe /功能。

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快速启动的服务吗?

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 简而言之,请检查此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在启动时启动我的 Windows 服务,并防止用户停止/重新启动它? - How can I start my Windows service on startup, and prevent users from stopping/restarting it? Windows 快速启动 - 如何确定上次启动/重新启动的时间 - Windows Fast Startup - How to determine when the last boot/reboot occured 如何在Windows启动时隐藏C#程序,但在正常打开该程序时不隐藏它? - How do I hide a C# program at Windows startup, but not when opening the program normally? 如何运行 windows 服务来安排从数据库中选择时间执行的作业? - How can I run windows service to schedule a job which will pick time from database to execute? 如何在C#中的Windows服务中执行批处理脚本? - How can I execute a batch script in a windows service in C#? 如何使用 C# 从 Windows 服务运行 EXE 程序? - How can I run an EXE program from a Windows Service using C#? 如何在启动时设置Windows位置 - How can I set the Windows position on startup 如何从 yaml 文件执行 C# 程序 - How can I execute a C# program from a yaml file 服务崩溃时如何以管理员权限运行程序? - How can I run a program with administrator permission when a service crashes? 使用 Windows 窗体初始化程序时,如何从工具条中选择要检查的按钮? - How can I select which button from a toolstrip is checked when the program is initialized using Windows Forms?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM