How to Schedule Batch Files to Run Automatically in Windows 10

Batch files are typically used to automate repetitive tasks in Windows computers, and the ability to schedule those tasks to run at designated times make it a powerful productivity tool. Today, we will learn how to schedule batch files in Windows 10 using the built-in Task Scheduler utility. Even if you’re not an advanced user, the simple instructions will help you create batch files to run commands on a schedule to help to automate tedious tasks on your PC.

Schedule Batch Files to Run Automatically in Windows 10

This tutorial will show you not only how to schedule batch files to run automatically in Windows 10, but also tell you about what it is and how it helps advanced users automate tasks in Windows computers. We will also teach you how to make a batch file on Windows 10. So without further ado, let’s look at what a batch file is and how to use them to execute commands on a schedule in Windows using Task Scheduler.

What is a Batch File?

Batch Files in Windows are script files, typically with a .bat extension, capable of running a series of commands in the Command Prompt in a specified sequence and according to triggers defined by the user. You can make a batch file to run just about any Command Prompt command, either manually or on a schedule.

BAT files are supported by DOS, OS/2 and Windows, but not all extensions are supported by all platforms. While .bat is used in DOS and Windows, other platforms like Windows NT and OS/2 also added the .cmd extension. Batch files for other environments may have other extensions.

Batch files are similar to Job Control Language (JCL), DIGITAL Command Language (DCL) and other systems on mainframe and minicomputer systems. Unix-like operating systems, such as Linux, have a similar way to automate tasks, called shell script, which is designed to be run by the Unix shell.

What Can I Do With Scheduled Batch Files?

As mentioned already, batch files help you automate repetitive tasks in Windows. You can use it to modify system settings, open up specific programs at specific times, launch multiple apps on a schedule, automate system backups and more. All supported versions of Windows (server and client) have a set of built-in Win32 console commands that you can use to automate tasks by using scripts or scripting tools. You can use either the Windows PowerShell, Windows Commands or Windows Script Host for automation.

What Special Apps Do I Need to Create Batch Files?

You don’t need source code editors or fancy IDEs to write BAT files in Windows. All you need is the good old Notepad, because a barebones text editor is all you need create a batch file in Windows.

How to Make a Batch File in Windows 10?

To start off, let’s write a simple batch file that will open multiple programs simultaneously at startup every time. I use Firefox every day for my surfing needs and Outlook to check my mails. So we’ll create a batch file to call the executable for both those programs that we want to open. For that, do the following:

  • Open Notepad and copy+paste the following line – @echo off

This will tell your computer not to give you any messages or popups while executing the  commands in the batch file.

  • Now we’ll add the two following lines. They will start Firefox and Outlook simultaneously every time the file is executed.

start “Firefox” “C:\Program Files\Mozilla Firefox\Firefox.exe”
start “Outlook” “C:\Program Files\Microsoft Office\root\Office16\Outlook.exe”

create batch file to run command

There are three basic elements to the above commands. The first is the ‘start’ command that is used in batch files to open programs.

Next is the name of the application – Firefox, Outlook, etc. It is for your convenience only, so you can use any name you want without affecting the end result.

Finally, there’s the app installation path. It will be determined by where the target program is installed. In my case, both are installed at “C:\Program Files\”. For 32-bit applications, the default location would be “C:\Program Files (x86)\”.

  • What you now have is a text file with a couple of lines of code. To save it as a batch file, click on File > Save As (see screenshot below).

  • You can save it under any name. I’m using “demo.bat” because this is a batch file created for demonstration purposes. Most importantly, make sure to change the file type to ‘All Files’ (*.*) instead of ‘Text Documents’ (*.txt).

You can create any number of files to perform tasks on your PC. Many batch files are also available for download online, but make sure you download them from reliable sources to avoid malware threats.

How to Schedule Batch Files

Now that we’ve been learnt how to create batch files, we will shift our attention to the (relatively) easier part where we set it to run on a schedule. In our case, we will set this file to run at Windows logon every time. To do this, we’ll use the built-in Windows Task Scheduler, which is an utility that lets users specify triggers to launch programs or scripts at pre-defined times or at specified time intervals.

  • To open Task Scheduler, search ‘schedule’ in the Windows search bar and click on the Task Scheduler icon.

  • Once the Task Scheduler window opens, click on ‘Create Basic Task’ on the right pane.

Note: You can also opt for more granular controls over the scheduling time, triggers and conditions by choosing ‘Create Task’ instead of ‘Create Basic Task.

  • Next, give your task any name you want. I chose the self-explanatory ‘Open Firefox and Office’. Now click on ‘Next’.

  • Now, we’ll need to choose a trigger. This will decide when the batch file will execute. In our case, we want it to run every time I log on, so I chose ‘When I log on’. Click on ‘Next’ once you’ve chosen an option.

  • Finally comes the most important part – choosing an ‘Action’. It will tell Windows what the task is all about in the first place. In our case, we want to run our batch script, so we’ll choose ‘Start a program’.

  • Next, we will point Windows towards the target batch file by clicking on the ‘Browse’ button and navigating to its location. In our case, we saved the file on the desktop itself, so the full path is “C:\Users\<username>\Desktop\Stuff\File\demo.bat”. Now click on ‘Next’ at the bottom.

  • Finally, click on ‘Finish’ on the next screen to create the task.

That’s it! You now know how to create and schedule batch files to automate simple but repetitive tasks in Windows.

Use Batch Files to Automate Tasks on Windows

As mentioned already, you can play around with other options within Task Scheduler to automate various tasks in Windows. For example, check out our article on scheduling automatic shutdown of Windows 10 computers by clicking on the link. Once you start getting the hang of it, you will see that the possibilities are endless. So which tedious, repetitive task do you want to automate using batch files? Let us know in the comments down below.

#Tags
Comments 0
Leave a Reply