---
title: "How to Set Up Batch File for Windows Task Scheduler"
description: "Here's a step-by-step guide for creating a task in the Windows task scheduler and adding a BAT file with the extension .bat."
url: https://srinimf.com/2023/03/18/advanced-productivity-techniques-adding-a-bat-file-to-windows-task-scheduler/
date: 2023-03-18
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2023/03/pexels-photo-7217957.jpeg?fit=1880%2C1253&ssl=1
categories: ["Oracle"]
tags: ["Windows Task Scheduler"]
type: post
lang: en
---

# How to Set Up Batch File for Windows Task Scheduler

Here’s a guide to create a new task in Windows Task Scheduler and add a BAT file. This guide will show you [how to](https://srinimf.com/2014/11/13/cics-purge-failed-transaction-tops/) upload data from a flat file to an Oracle table. The main focus is on adding an SQL Loader script to the BAT file.

Related[Explained SAS Macro Here’s Tutorial](https://srinimf.com/2012/05/19/mainframe-with-sas/)

Table of contents

1. [Create a Task in Windows task Scheduler](https://srinimf.com/2023/03/18/advanced-productivity-techniques-adding-a-bat-file-to-windows-task-scheduler/#create-a-task-in-windows-task-scheduler)
2. [Creating a BAT file](https://srinimf.com/2023/03/18/advanced-productivity-techniques-adding-a-bat-file-to-windows-task-scheduler/#creating-a-bat-file)
3. [How to Load Data from Flat file to Oracle Table (SQLLDR)](https://srinimf.com/2023/03/18/advanced-productivity-techniques-adding-a-bat-file-to-windows-task-scheduler/#how-to-load-data-from-flat-file-to-oracle-table-sqlldr)

## Create a Task in Windows task Scheduler

Search for a** Task scheduler** in windows search.

![Task scheduler](https://i0.wp.com/srinimf.com/wp-content/uploads/2023/03/image-11.png?resize=343%2C232&ssl=1)

Click on create a New task

![Create new task](https://i0.wp.com/srinimf.com/wp-content/uploads/2023/03/image-12.png?resize=1304%2C609&ssl=1)

Add details for the General tab

![General tab](https://i0.wp.com/srinimf.com/wp-content/uploads/2023/03/image-13.png?resize=923%2C538&ssl=1)

Add trigger details: Click on the New tab

![Triggers tab](https://i0.wp.com/srinimf.com/wp-content/uploads/2023/03/image-14.png?resize=636%2C484&ssl=1)

Enter the Date and Time of frequency [to run](https://srinimf.com/2016/03/08/mainframe-batch-jcl-to-compile-pli-program/) the scheduled job.

Related[The Easiest Way to Run Terraform in Visual Studio Code](https://srinimf.com/2023/04/01/the-easiest-way-to-run-terraform-in-visual-studio-code/)

![Trigger details](https://i0.wp.com/srinimf.com/wp-content/uploads/2023/03/image-15.png?resize=589%2C513&ssl=1)

In the actions tab, you need to attach the BAT file.

Here’s my [previous post](https://srinimf.com/2023/02/25/how-to-write-date-logic-in-sql-loader-control-file/) on running SQL Loader script at Command Prompt. Add the same to the BAT file. So you can automate the task in the Windows task Scheduler. 

## Creating a BAT file

Go to any drive you wish. For example, in the D:/ drive, open notepad, and add contents as below:
Save it as “Myscript.bat”:

```
"C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools\Command Prompt.lnk" /c "SQLLDR database-name/password@portname control=D:/p.ctl, skip=1"
```

The first piece of code: “C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools\Command Prompt.lnk” tells open the CMD.

The second piece** /c** tells CMD to open, execute and close it. The third piece is the actual script to run.

![Actions tab](https://i0.wp.com/srinimf.com/wp-content/uploads/2023/03/image-16.png?resize=635%2C478&ssl=1)

Just add the script to the Actions tab.

![Adding BAT file](https://i0.wp.com/srinimf.com/wp-content/uploads/2023/03/image-17.png?resize=461%2C506&ssl=1)

That’s all. Your scheduled job will execute as per the time you choose.

References

- [How to Create Job in Windows Task Scheduler – Guide from Microsoft](https://learn.microsoft.com/en-us/windows/win32/taskschd/about-the-task-scheduler)

## How to Load Data from Flat file to Oracle Table (SQLLDR)

[steps-to-load-data-flat-file-to-table-in-oracle](https://srinimf.com/wp-content/uploads/2023/12/steps-to-load-data-flat-file-to-table-in-oracle.docx)[Download](https://srinimf.com/wp-content/uploads/2023/12/steps-to-load-data-flat-file-to-table-in-oracle.docx)

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2023%2F03%2F18%2Fadvanced-productivity-techniques-adding-a-bat-file-to-windows-task-scheduler%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2023%2F03%2Fpexels-photo-7217957.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=How%20to%20Set%20Up%20Batch%20File%20for%20Windows%20Task%20Scheduler)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2023/03/18/advanced-productivity-techniques-adding-a-bat-file-to-windows-task-scheduler/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2023/03/18/advanced-productivity-techniques-adding-a-bat-file-to-windows-task-scheduler/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2023/03/18/advanced-productivity-techniques-adding-a-bat-file-to-windows-task-scheduler/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2023/03/18/advanced-productivity-techniques-adding-a-bat-file-to-windows-task-scheduler/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20to%20Set%20Up%20Batch%20File%20for%20Windows%20Task%20Scheduler&body=https%3A%2F%2Fsrinimf.com%2F2023%2F03%2F18%2Fadvanced-productivity-techniques-adding-a-bat-file-to-windows-task-scheduler%2F&share=email)
-

### Like this:

Like Loading…