Batch files are one of the best ways to automate tasks. Add on to that the ability to schedule those batch files and you’ve got a powerful productivity tool.
Scheduling Batch Files in Windows Using Task Scheduler
After you make a batch file to automate a job, you’ll want it to run regularly. The easiest way to do that is with the Task Scheduler built into Windows. It’s a tool that automatically runs jobs on a schedule. Task Scheduler will have many scheduled tasks already. Windows and programs use scheduled tasks, too. Also, note that the script will Run only when the user is logged on. You can change this to Run whether user is logged on or not if you want it to run anytime.Note the other options. For most tasks, the default values are sufficient. Be aware that you can make these changes if needed. On a schedule is the most popular one and the one we’ll use for this exercise. We selected Daily for this example. You can also decide when the schedule starts and recurs. The last two are deprecated and not supported options anymore. It’s best not to use them when you schedule batch files. Leave it on the default Start a program. Enter the full path to the script. Use the Browse button to go to the script, and select it.The Add arguments and Start in fields are blank. You might use these when you progress to more complicated scripts and tasks. You’ll definitely need these to schedule PowerShell scripts. Select OK to continue. When the task finishes, look at the Last Run Result column. You should see The operation completed successfully.If it says anything else, try using the F5 button to refresh the screen. If it still says anything else, there’s something wrong with your script or the way you scheduled the task. You have some troubleshooting to do.
What About the Conditions and Settings Tabs?
Yes, there are two tabs we didn’t discuss in the above instructions. For most tasks, you don’t need to go into these tabs. There are default values set in them that generally are best left alone. Still, let’s take a look at the tabs.
Create Task – Conditions
These settings relate to the state of the computer. If the task takes a lot of resources or can interrupt the person using it, change the Idle section. The Power section defaults to having Start the task only if the computer is on AC power and Stop if the computer switches to battery power already checked.In most cases when you schedule batch files, it’s fine to leave these checked. We set some computers to go to sleep to save power when they’re not being used. If the computer is asleep, the task won’t run. If that’s the case, you’ll want to check the Wake the computer to run this task box. These days, a computer is almost always connected to a network. Still, if your task depends on a solid network connection, change the Network section.
Create Task – Settings
The Settings tab relates to the behavior of the task. That means how the task is running. The Allow task to be run on demand is checked by default. The other choices relate to situations where a task gets skipped or fails.Some tasks may get stuck in a loop, or not run because their trigger conditions aren’t met. These are the settings you’d adjust to account for that. For most tasks, the default settings are good.
What Can I Do With Scheduled Batch Files?
Once you know how to schedule tasks, the mind can race with ideas of things to automate. You can auto delete files, set favorite programs to open on login, or automatically clear the print queue of failed jobs. Whatever task you do repeatedly, you can probably script it and schedule it.