简体   繁体   中英

How to reboot Windows 8/10 and go to Advanced Boot options with WinAPI?

I know that one can reboot a workstation using InitiateShutdown API. I'm curious how to do I reboot and go to "Advanced Boot" option window that is available on Windows 8/10? (I'm asking about WinAPI or a registry setting.)

在此输入图像描述

PS. The same can be achieved by calling:

shutdown \r \o

For Windows 8 and up you can use the undocumented dwShutdownFlags value 0x400 that will initiate reboot and then show advanced boot menu options. That flag can be combined with SHUTDOWN_RESTART , SHUTDOWN_RESTARTAPPS , SHUTDOWN_FORCE_OTHERS , SHUTDOWN_FORCE_SELF .

As such:

DWORD dwResult = InitiateShutdown(NULL, NULL, 
    30,                                            //Use 30-second timeout 
    SHUTDOWN_RESTART | 0x400,                      //Reboot with advanced menu options
    SHTDN_REASON_FLAG_PLANNED | 
    SHTDN_REASON_MAJOR_APPLICATION |
    SHTDN_REASON_MINOR_OTHER);

Keep in mind though that this flag is undocumented, so use it at your own risk!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM