Reputation: 13674
I would like to know how it is possible to perform a task directly after the explorer process is started. My goal is to process some tasks directly after login on Windows 8, as the "Run" entry in the registry is not immediately executed.
Upvotes: 1
Views: 353
Reputation: 10181
Use the userinit registry key, it is the first process to run. I get to the DLL part later.
Rigth after Winlogon gets a token for the user (when that user is authenticated) it lauch all the processes listed un the userinit key, in the order they are listed.
But beware : your process must exit after a few seconds, or else Windows will think that there is a problem with the creation of your desktop, and it will replace your desktop with a default desktop. To test, change the userinit registry key to
notepad.exe,userinit.exe
You can get around this limitation by making your process relaunch itself at first launch. For example, when myprocess.exe
is run :
If there is no command line
get the process name and path (with GetModuleFileName, fyi)
start the process again with /go as a parameter
exit
Now, your original question mentions loading a DLL, and all I talk about is about process. Calling rundll32 on your dll will load it and calling an function on it. From your answers to comments, it looks like using a process is also OK.
Upvotes: 1
Reputation: 36896
You could write a shell extension which will be loaded into Explorer right away.
Small word of caution: in all situations like this there is a race of "But I want my application to be first!" Except everyone wants the same thing, so in effect there's no generalized solution to the problem when talking about a platform like Windows. But if you are more specific about why it's so important that you run before other apps, it would be easier to help. For example Skype runs at startup, and there's no problem that it starts up slightly delayed. It's expected when the system is trying to do 100 things at the same time. Similar scenario is explained here.
Upvotes: 1