Windows Task Scheduler: Techniques to Create BAT File

Here’s a step-by-step guide to creating a new task in windows task scheduler and adding a BAT file. It will upload data from a flat file to an oracle table. The prime point you will know here is how to add SQL Loader script to the BAT file.

Table of contents

  1. Create a Task in Windows task Scheduler
  2. Creating a BAT file

Create a Task in Windows task Scheduler

Search for a Task scheduler in windows search.

Task scheduler

Click on create a New task

Create new task

Add details for the General tab

General tab

Add trigger details: Click on the New tab

Triggers tab

Enter the Date and Time of frequency to run the scheduled job.

Trigger details

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

Here’s my previous post 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

Just add the script to the Actions tab.

Adding BAT file

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

References

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.

Start Discussion

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.