- To configure the “RunOnce” key, open the “HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce” Registry path and create a String Value with the command to run.
- To configure the “Run” key, open the “HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run” Registry path and create a String Value with the command to run.
- You can use “!” for the name of the key to ignore deletion or “*” to run the key in Safe Mode.
On Windows 11 (and 10), you can use the “Run” and “RunOnce” Registry keys to run apps and scripts during startup as the user logs in to the account. Of course, you can always use run programs at logon with the “Startup” folder, but the Registry is another approach you have at your disposal.
The “Run” key allows you to execute a program whenever the user logs in to their Windows account. On the other hand, the “RunOnce” key runs a program only once, and then the system removes the key.
Although you can use the “Run” key every time the user logs in, the “RunOnce” key should only be used for those “one-time” cases, such as to complete app setup, map a networked drive once, or change a setting, and you shouldn’t use it continuously.
You can use these Registry keys on a per-user or per-device basis and configure multiple entries inside these keys. The only caveat is that the command cannot have more than 260 characters.
In this guide, I will outline what you need to know to leverage the Registry to run programs at logon on Windows 11 (or even on Windows 10).
Configure RunOnce key on Windows
To set up the RunOnce key through the Registry, use these steps:
-
Open Start on Windows 11.
-
Search for regedit and click the top result to open the Registry.
-
Open the following path to configure the “RunOnce” key for the current user:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
-
Open the following path to configure the “RunOnce” key for the machine:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
-
Right-click the Run key, choose New, and select the String Value option.
-
Confirm a name that describes the command and press Enter.
Quick tip: By default, the system will delete the keys before they even run, but you can append a “!” (exclamation mark), such as “!MyRunKey,” to delete the string after the command runs successfully. You can also append the “*” (asterisk), such as “*MyRunKey,” to run the command in Safe Mode. Otherwise, the keys will be ignored. -
Right-click the newly created string and choose the Modify option.
-
Confirm the command to the script or program to run.
Quick tip: You can also specify additional options as necessary to run the command. -
Click the OK button.
After you complete the steps, the system will run the command in the string one time, but only for users who are part of the “Administrators” group, meaning that this won’t work for standard users.
Configure Run key on Windows
To configure the “Run” key on Windows 11 (or 10), use these steps:
-
Open Start.
-
Search for regedit and click the top result to open the Registry.
-
Open the following path to configure the “Run” key for the current user:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
-
Open the following path to configure the “Run” key for the machine:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
-
Right-click the Run key, choose New, and select the String Value option.
-
Confirm a name that describes the command and press Enter.
-
Right-click the newly created string and choose the Modify option.
-
Confirm the command to the script or program to run.
Quick tip: You can also specify additional options as necessary to run the command. -
Click the OK button.
Once you complete the steps, the system will run the commands in the Registry string every time the user logs in to the account.