开发者

Delayed start using RunOnce

开发者 https://www.devze.com 2023-03-26 11:31 出处:网络
I have a program that I want to start at Windows start up. So I wrote the program to the registry value SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce. The program runs immediately when Windows

I have a program that I want to start at Windows start up. So I wrote the program to the registry value SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce. The program runs immediately when Windows starts up.

However, it runs the program before any of the other processes are started. I would like to have my program start up after my Desktop has started and all the other system processes have started. How would I do this?

Edit: So I have added a delay in my program. None of the processes like desktop start until开发者_如何学Go after my program has run no matter what kind of delay I put in my program.


According to Microsoft:

With the exception of the HKEY_LOCAL_MACHINE...\RunOnce key, all keys and their entries are loaded asynchronously. Therefore, all entries in the RunServices and RunServicesOnce keys can potentially run at the same time.

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.

So does that mean if you put a program that does Sleep(INFINITE) in the RunOnce key, it will prevent your machine from starting up? Interesting.

Just use one of the other keys mentioned in that article. Or if you need the semantics of RunOnce, use a helper program that exits after launching the real program.

0

精彩评论

暂无评论...
验证码 换一张
取 消