How to Schedule a Batch File in Windows step by step.
If you don’t automate things, you are missing computers. The real purpose of computers is to do tedious, repetitive things that people no longer want to do.
Batch files are one of the best ways to automate tasks. Add to that the ability to schedule these batch files and you have a powerful productivity tool.
Scheduling Batch Files in Windows Using Task Scheduler
Once you’ve created a batch file to automate the job, you’ll want it to run regularly. The easiest way to do this is by using the Windows built-in task scheduler. It is a tool that automatically launches scheduled tasks.
- Click the Windows Start button and type scheduler. The best result should be Windows Task Scheduler.
There will already be many scheduled tasks in the task scheduler. Windows and programs also use scheduled tasks.
- Create a new folder for your tasks so you don’t get lost among other tasks that are already here. Right-click the Task Scheduler Library and select New Folder … or select New Folder from the Actions pane on the right side of the window.
Enter a name for the new folder. Make it something meaningful.
- Right-click the new folder and select New Task … or select New Task … from the Actions pane.
- The New Task window opens on the General tab. Enter a meaningful name for the task in the Name: field. In the Description: field, write what the task does. It is recommended to specify the location of the script to be called. This makes it easier to change the task and scenario in the future.Pay attention to the “Change User or Group” button. This allows you to run the script as a different user. If your batch file requires administrator rights, you must change the user to administrator. It will ask you for your administrator password, so this is not a shortcut to hijack your computer.
Also, note that the script will only run when the user is logged in. You can change this value to Run regardless of whether the user is logged in or not if you want it to start at any time.
Pay attention to the other parameters. The defaults are sufficient for most tasks. Keep in mind that you can make these changes if needed.
- Select the Triggers tab. Triggers are what will decide when the task starts. Select New to create a trigger.
- There are many options in the New Trigger window.
Look around to see what options you have.
Select the base trigger task from the Start Tasks drop-down menu. Possible options are:
- On schedule
- At login
- At startup
- Â On event
- then creating/modifying a task
- Â connecting to a user session
- When disconnecting from a user session
- When a worker is locked Station
- Unlock at Workstation
Scheduled is the most popular one, and we will use it in this exercise.
There are also options for configuring the schedule. The following options are available:
For this example, we chose Daily. You can also decide when the schedule starts and repeats.
- In advanced settings, you can set additional parameters related to the task launch. This task will repeat every 5 minutes indefinitely. Note that the Enabled box is checked by default. This is the first place to check when troubleshooting why a scheduled task is not starting. After setting up the trigger, click OK.
- Select the Actions tab and then New to tell the scheduled task what it is about to do.
From the Action drop-down menu: you have a choice:
- Start the program.
- Send email
- Show message.
The last two are deprecated and no longer supported. It is best not to use them when scheduling batch files. Leave the default. Run the program.
Enter the full path to the script. Use the Browse button to navigate to and select a scenario.
The Add Arguments and Start In fields are empty. You can use them when moving on to more complex scenarios and tasks. You will definitely need them to plan your PowerShell scripts. Click “OK” to continue.
- The task is scheduled. Click OK to close the window and return to Task Scheduler. Select the task you just created and test it. Right-click the task and select Run, or select Run from the Actions pane.
When the task completes, look at the Last Run Result column. You should see that the operation completed successfully.
If anything else appears, try pressing F5 to refresh the screen. If it still says something else, there is something wrong with your script or the way you schedule the task. You need to troubleshoot.
What About the Conditions and Settings Tabs?Â
Yes, there are two tabs that we did not discuss in the instructions above. For most tasks, you don’t need to go to these tabs. They are set to default values, which are best left alone. However, let’s take a look at the tabs.
Create task – Conditions
These settings are related to the state of the computer. If the task requires a lot of resources or can interrupt its execution, change the “Idle” section.
In the Power section, by default, the task starts only if the computer is connected to AC power, and in the Stop section, if the computer switches to battery power, the checkbox is already checked.
In most cases, when you are planning batch files, you can leave these checked. We put some computers into sleep mode to save energy when not in use. If the computer is asleep, the task will not start. In this case, select the Wake-up computer to perform this task check box.
A computer is almost always connected to the network these days. However, if your task depends on a reliable network connection, change the “Network” section.
Create task – Settings
The Settings tab refers to the behavior of the task. This means how the task is performed. By default, the Allow task launch on request check box is selected. Other options related to situations where a task is skipped or not completed.
Some tasks may get stuck in a loop or not execute because the conditions for starting them are not met. These are the parameters that you must change for this. The default settings are suitable for most tasks.
What Can I Do With Scheduled Batch Files?
Once you learn how to schedule tasks, your mind can compete with ideas that need to be automated. You can automatically delete files, set favorites to open at login, or automatically clear the print queue of failed jobs. Whatever task you do repeatedly, you can probably create a script and schedule it.
How to Schedule a Batch File in Windows step by step
How to Schedule a Batch File in Windows step by step.
create scheduled task batch file
how to make a batch file run at a certain time without task scheduler
how to run batch file automatically every 5 minutes without task scheduler
batch file commands
create batch file to run command
run batch file on startup windows 10
task scheduler batch file windows 10
create batch file to run exe