Windows Run a Script on Startup

Advertisement

Advertisement

Introduction

You can specify what programs you want to run on Windows boot. All you have to do is add the script, executable, or shortcut in to the startup folder. Alternatively you can use scheduled tasks to manage startup scripts. This will show you how to use both methods.

Using startup folder to launch scripts

The easiest way to trigger scripts to run at startup is to drop then inside the startup folder.

To easily navigate to the startup folder, Windows has an alias available: shell:startup. Use shell:common startup

You can get to the startup folder a couple ways:

  1. Open the Run dialog with WindowsKey+R and enter shell:startup.
  2. In the command prompt, enter explorer shell:startup.

Simply copy your files that you want run on startup in to the folder.

For example, in Windows 10, these paths work for me for user and global:

%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
%ProgramData%\Microsoft\Windows\Start Menu\Programs\StartUp

Enable and disable startup apps

Many apps run on startup that do not have any files in the startup folder. You can manage the startup apps from the Task Manager | Startup tab or by running taskmgr.exe.

In addition you can disable scripts from your startup folder so you don't have to remove them to disable them. Right click on an item to enable or disable it.

Using scheduled tasks

An alternative to the startup folder is scheduled tasks. You can schedule a task to run on startup.

For a GUI, run taskschd.msc to create, delete, enable, disable, and otherwise manage all scheduled tasks.

To manage scheduled tasks from the command prompt, use schtasks.exe. This program will allow you to create, delete, and run scheduled tasks. You can get help about the commands by running one of the following:

schtasks
schtasks /?
schtasks /Run /?
schtasks /End /?
schtasks /Create /?
schtasks /Delete /?
schtasks /Query  /?
schtasks /Change /?
schtasks /ShowSid /?

Remember to run an administrator command prompt for these commands. Example for creating a script to launch on startup as local user on login:

schtasks /create /tn "MyCustomTask" /sc onlogon /tr "cmd.exe /c pause"

You can tell a script to run as system on start like this:

schtasks /create /tn "MyCustomTask" /sc onstart /ru system /tr "cmd.exe /c pause"

Conclusion

After this, you should understand how easy it is to launch your own programs on startup.

If you want to run a long-running or background service, consider setting up a Windows service so you can manage it with services.msc.

Advertisement

Advertisement