How to create batch file and execute as a windows scheduler?

This article will explain you about how to run your batch file from task scheduler? You can run your console application by sending required arguments using this batch file. I have included simple DOS commands in it. I hope it will be useful for you all.

How to create batch file and execute as a windows scheduler?
It is always a best practice to create batch file if you want to run set of commnads repeatedly. You can schedule it by using Task scheduler.
Steps to create batch file :
1) Open notepad and write the sequence of commands you want to execute. For e.g

cd D:\TestFolder
You can even give your console application's dll or jar(incase of java) with required arguments.

2) Save the file with extension .bat
3) Double click on the file and check whether your set of commands are getting executed manually or not.
4) If you want to see the command prompt output of your batch file then put "PAUSE" command at last sentence.

Steps to create scheduler:
1) Assuming that you are using Windows 7 operating system. You have to go to Control Panel->System and Security->Administrative Tools->Task Scheduler.
2) In Actions tab -> click on create basic task menu. Put name and description in the textboxes which will appear.
3) Go to next, it will ask you when do you want to start your task? Whether it is daily, weekly, monthly, one-time, When the computer starts , when I log on or when a specific event is logged?
You have to choose one option from these.
4) Click on next to set the start time , you need to mention it should recur how many times per day?
5) Click on next to set what actions do you want the task to perform? Is it "Start a program" , "Send an email" or "Display a message"?
As we want to run batch program from this task scheduler. We have to select "Start a program ". Click on next and browse batch file we have created above.
6) Click on next and go through the summary of all steps we have followed to create task scheduler.
7) Click on "finish" button and your batch program will run on the time set in the scheduler.


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: