Search code examples
windowslanguage-agnosticstartup

Run Windows application on startup; operative differences between registry, autostart and task scheduler?


Recently, I once again came across the problem of having to run my Windows app on startup and wondered which of the options is the most usual one and causing least trouble long term.

Registry

Add string value of the path to your exe to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run or \HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run for x86 applications running on a x64 Windows.

  • Feels the most natural
  • Fairly easy, especially when using frameworks simplifying registry entry creation
  • When uninstalling an application, you could end up with a dead registry entry
  • User won't be able to edit this entry

Autostart

Create a .lnk inside the user or system wide autostart folder (shell:startup).

  • Able to do it programmatically
  • Very easy to create, add arguments and modify
  • User is able to edit entries in his usual environment

Task scheduler

Create a 'When the computer starts' or 'When I log on' run entry in the Task Scheduler.

  • Able to do it programmatically
  • There is a GUI, but I would assume the average user won't find it

So what are further considerations when selecting an option?


Solution

  • Registry is always being used by production software, since that's the most controlled way and Windows suggests it.

    Pros:

    1. No need to enter the users personal space (powershell:startup)
    2. Option to autostart the software only once (windows cleans up the registry)
    3. Decide if the software should autostart for the whole local machine or the current user
    4. Can be executed even when the machine is started in safe mode by using RunOnce with an exclamation point (!)

    Here you can read more information about using Run and RunOnce Registry Keys.

    shell:startup(not recommended) is the personal startup folder of the user, where shortcuts are being stored, that have been created & copied over by the user. The user will also experience an error prompt, if the application has been deleted, but the shortcut still remains. [BAD USER EXPERIENCE]

    Task Sheduler is great for scripting, conditional event triggering and mostly used by Administrators. This option would be overkill, since Registry is much simpler and doesn't leave a Task Event, that the user has to disable on his own.

    There is a GUI, but I would assume the average user won't find it

    Task Manager [Startup tab] will display applications that will be automatically executed by Windows (registry & startup), which allows the user to enable/disable the software from doing that, so that's not an issue.

    TLDR: Registry is by far the most used and best option to automatically run software.