Windows Startup folder environment variable
Solution 1
The startup priority in Windows is as follows, listed from first to start to last to start:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
SystemDrive\Documents and Settings\All Users\Start Menu\Programs\Startup
SystemDrive\Documents and Settings\username\Start Menu\Programs\Startup
The last two items relate to Windows XP days. Which relate to %PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\Startup
And yes, to answer your question, Windows Vista, 7, 8, and 10 use the same startup folder.
So, if you want your program to run first, always use: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Otherwise, the startup folder, will load after everything else is loaded.
Solution 2
You want to look up the folders from the shell namespace, e.g. by passing FOLDERID_Startup
(or FOLDERID_CommonStartup
) to the functions to lookup folder from the shell namespace.
The registry entries (HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run and others) mentioned in another answer are better options. See here
Microsoft also has an article describing the relative order of the different methods.
(The startup folder has the advantage of being easy(ish) for the user to control)
Related videos on Youtube
marcosbontempo
Updated on September 18, 2022Comments
-
marcosbontempo almost 2 years
I'm developing a setup.exe for my application that copies it to the startup folder with the following path:
cd %PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\Startup
Now I'm worried if this path could change in different versions of Windows. Does anybody knows if the startup folder path is always the same? There is a better way to configure an application to start every boot?
Any tip will be very helpful,
Thanks