Monday 4 February 2013

Create a batch file (.bat) to invoke a web URL

A batch file contains a series of DOS commands, and is commonly written to automate frequently performed tasks. Instead of typing the same commands over and over, you can simply double-click the batch file or it can be scheduled in server machines.

Batch file can be easily created by creating a simple text file and renaming it to filename.bat
Below are the simple steps -

Open a notepad
Type the following
start iexplore http://saurabh-shubham.blogspot.in/
Save the notepad as batch.bat and run it.
If you want to more sites repeat the same step again like...
start iexplore http://www.yahoo.com
start iexplore http://www.google.com
start iexplore http://www.gmail.com

In my case, I wanted to invoke a web service, wait/pause for some time to execute it and finally close the browser. Here are my lines in blue -
start chrome http://someservice.svc :- Instead of IE, I prefer chrome.
PING 127.0.0.1 -n 6 :- This will ping the local server for 5 seconds. By that time my service gets executed.

taskkill /f /IM chrome.exe :- Finally kill the process to close the browser.

1 comment:

  1. brillant piece of information, I had come to know about your web-page from my friend hardkik, chennai,i have read atleast 9 posts of yours by now, and let me tell you, your webpage gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanx a million once again, Regards, How to create batch file

    ReplyDelete