Set up RunOnce and Run Registry keys for scripts and apps at logon

You can use the Registry to run scripts and apps at every logon or once, and in this guide, I will show you how on Windows 11 and 10.

Windows 11 RunOnce Registry key
Windows 11 RunOnce Registry key / Image: Mauro Huculak
  • 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).

Warning: It’s crucial to note that modifying the Registry can cause serious problems if not used properly. It’s assumed you know what you’re doing and created a full backup of your system before proceeding.

Configure RunOnce key on Windows

To set up the RunOnce key through the Registry, use these steps:

  1. Open Start on Windows 11.

  2. Search for regedit and click the top result to open the Registry.

  3. Open the following path to configure the “RunOnce” key for the current user:

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
  4. Open the following path to configure the “RunOnce” key for the machine:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
  5. Right-click the Run key, choose New, and select the String Value option.

    Registry RunOnce create string

  6. 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.
  7. Right-click the newly created string and choose the Modify option.

  8. Confirm the command to the script or program to run.

    Registry RunOnce key configuration

    Quick tip: You can also specify additional options as necessary to run the command.
  9. 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:

  1. Open Start.

  2. Search for regedit and click the top result to open the Registry.

  3. Open the following path to configure the “Run” key for the current user:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
  4. Open the following path to configure the “Run” key for the machine:

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
  5. Right-click the Run key, choose New, and select the String Value option.

    Registry create Run string

  6. Confirm a name that describes the command and press Enter.

  7. Right-click the newly created string and choose the Modify option.

  8. Confirm the command to the script or program to run.

    Registry Run key configuration

    Quick tip: You can also specify additional options as necessary to run the command.
  9. 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.

About the author

Mauro Huculak is a Windows How-To Expert who started Pureinfotech in 2010 as an independent online publication. He has also been a Windows Central contributor for nearly a decade. Mauro has over 14 years of experience writing comprehensive guides and creating professional videos about Windows and software, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 20 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter), YouTube, LinkedIn and About.me. Email him at [email protected].