How to Run Batch File on Task Scheduler?
While there are moments to want to run Task Scheduler automatically, for such occasions, you can use this method. First, we are going to understand what the batch file is then we will run batch files on the task scheduler. So, let’s begin the process.
Table of Contents
How to run a batch file as an administrator in the task scheduler?
A batch file is a script file in DOS that will follow up on your commands and proceed. You can either run it manually or do it automatically.
Manually run a batch file
Create any batch file on your Windows. Once created then you are going to select the batch file. Now right-click on the batch file and select Run as administrator option. Soon the system will run the batch file and all the commands file inside and the process will begin.
When the entire process got completed then the newly popped CMD windows will either close or will display a notification with the process being completed.
Automatically run the batch file
There is also the option to run any batch file or task automatically. For this, you will need a task schedular on your Windows.
Open the Start menu and then search for Task Scheduler.
Open Task Scheduler and then go for Create Basic Task. Select Action which is in the right pane of Task Scheduler.
Now in Create Basic Task, you will type any name and click on Next.
Select the Trigger option and you will find different options. From daily to running on specific occasions, select one of the options and click on Next. Then you will be placed to insert more details about the occasion. Things like date, and will be asked.
In Action, click on Start a Program and then click on Next.
Click on Browse and find the batch file. Once the file is selected then you will click on Finish. Now, the Task Scheduler will run the file on the selected occasion.
How to create a batch file for task scheduler?
For running any task on Task Scheduler with the batch file, you have two options. You can either create one to run a single task or to run multiple tasks.
Run a single task on Task Scheduler
Here we will run a single task on Task Scheduler using a batch file.
Begin the process by going to Start. Search for Notepad and open a new one. Paste the commands below inside the new notepad.
@ECHO OFF
ECHO Hello World! Your first batch file was printed on the screen successfully.
PAUSE
Here the commands above have created a task of printing “ECHO Hello World! Your first batch file was printed on the screen successfully.” on CMD.
NOTE: any Quick Note is created with “.bat”, “.cmd” or “. btm” extension. Creating any batch file without these extensions won’t run at all.
TIPS:
ECHO- is used to print texts after space.
@ ECHO OFF- is used to disable any prompt once the commands are applied.
PAUSE- allows users to open windows. Then it will execute all the commands.
You are going to click on File > Save as. Save the file by any name that you prefer and don’t forget to use the “.bat” extension at the end. Use one of the methods above to run this batch file on your Windows.
Create a batch file that runs multiple tasks on Task Scheduler
Now let’s create a batch with which you can run multiple tasks at once. Start the process by going to Start > Notepad. Paste all the commands below on notepad.
@ECHO OFF
:: This batch file details Windows 10, hardware, and networking configuration.
TITLE My System Info
ECHO Please wait... Checking system information.
:: Section 1: Windows 10 information
ECHO ==========================
ECHO WINDOWS INFO
ECHO ============================
systeminfo | findstr /c:"OS Name"
systeminfo | findstr /c:"OS Version"
systeminfo | findstr /c:"System Type"
:: Section 2: Hardware information.
ECHO ============================
ECHO HARDWARE INFO
ECHO ============================
systeminfo | findstr /c:"Total Physical Memory"
wmic cpu get name
wmic diskdrive get name,model,size
wmic path win32_videocontroller get name
wmic path win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution
:: Section 3: Networking information.
ECHO ============================
ECHO NETWORK INFO
ECHO ============================
ipconfig | findstr IPv4ipconfig | findstr IPv6
START https://support.microsoft.com/en-us/windows/windows-10-system-requirements-6d4e9a79-66bf-7950-467c-795cf0386715
PAUSE
The commands above are going to display all about your system. You will find all the things about your system in three different sections.
The first category is about WINDOWS INFO, the second HARDWARE INFO, and the last is about NETWORK INFO.
NOTE: any Quick Note is created with “.bat”, “.cmd” or “. btm” extension. Creating any batch file without these extensions won’t run at all.
ECHO- is used to print texts after space.
@ ECHO OFF- is used to disable any prompt once the commands are applied.
PAUSE- allows users to open windows. Then it will execute all the commands.
TITLE- will enable you to print custom names on the title bar. This is also used for documentation.
:: – allows you to write commands on CMD.
START- is used to open sites on your default browser on your Windows. The site can differ, as you will be the one to insert the URL.
You are going to click on File > Save as. Save the file by any name that you prefer and don’t forget to use the “.bat” extension at the end. Use one of the methods above to run this batch file on your Windows. You can also use batch files to activate your Windows. So, here is how to create a batch file to activate Windows.
Task Scheduler not running batch file?
If you have created a batch file and want to use it on Task Scheduler but can’t then you will need to check the extension. Make sure the extension is either “.bat”, “.cmd”, or “.btm”. most of the time users can’t run any batch file due to the wrong extension.
This is also possible that you have used the wrong commands inside your batch file.
Windows 10 run batch file on schedule without Task Scheduler
If you don’t want to use Task Scheduler to run batch files then you will need to do it manually. For this, you will select your batch file. Right-click on it and run it as administrator. The batch file will run and you haven’t used Task Scheduler.