How to create a batch script and a task scheduler on Windows server 2012

Biljana Jelić
4 min readFeb 11, 2020

A batch file is a script file which contains series of commands that get executed one after the other, in a sequence. A batch file is created in a simple plain text file (Notepad or WordPad) with .bat extension and is executed by the command-line interpreter (cmd.exe known as Command Prompt in Windows).

They are usually created to automate jobs that need to be done periodically such as deleting files or logs to free up disk space, backups on a daily/monthly/weekly basis, testing or checking a list of active/inactive users or addresses in network, creating daily/weekly/monthly reports with information about disk usage, file sizes etc… In a nutshell, the main functionality of these kinds of scripts is to avoid writing the same code over and over again and to automate tasks and ease the work required for certain regular tasks.

If you periodically do something in the same way, it should be automated.

This article demonstrates how to create a simple batch script which is deleting unnecessary log files on the server (to make more space on the disk), and set up a scheduler task to execute this script automatically (Windows Server 2012 in this article).

1. Create batch script:

--

--

Biljana Jelić
Biljana Jelić

Written by Biljana Jelić

SQL, SSMS, PL/SQL , Data migration, ETL, Oracle Apex, Python #techgirls

No responses yet