简体   繁体   中英

Windows stops booting while EXE in runonce is active

I have written an MFC app (executable) that performs some tasks, and which is started via "Runonce" in Windows 7 registry.

My problem is that windows, or especially windows explorer does not boot until I quit that exe. How can I make my EXE run asynchronously, so that it can perform tasks, but Windows will continue booting? Is there some basic thing I am missing here?

Thanks :)

It maybe such an issue if you put your application into

HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce

As it said on http://support.microsoft.com/kb/179365/en-us

Entries in the HKEY_LOCAL_MACHINE\\...\\RunOnce key are loaded synchronously in an undefined order.

Because the HKEY_LOCAL_MACHINE\\...\\RunOnce key is loaded synchronously, all of its entries must finish loading before the HKEY_LOCAL_MACHINE\\...\\Run, HKEY_CURRENT_USER\\...\\Run, HKEY_CURRENT_USER\\...\\RunOnce, and Startup Folder entries can be loaded.

Suitable workaround for this situation maybe adding something like this as registry value in HKLM\\...\\RunOnce

cmd /c "start "myAppTitle" "path to myMegaApp.exe" "params""

It is can be successfully used to bypass UAC promt (make sure that you writing registry key as admin and login after reboot as user of admin group).

Another way

  • put your app to HKCU\\...\\RunOnce (which entries load asynchronously)(if you don't need admin rights for your application)
  • use Task Scheduler API which provides a lot of interesting stuff

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