Generally speaking batch files are text files with .bat extension with group of commands that you can execute on command line (cmd). They are generally used to group multiple tasks for smooth and reliable execution, to automate stuff, for repeated jobs etc. Admins generally use these files for administrating the system and also for deployment.
Enough said lets see how we can create one and work with it.
You can use your favorite text editor. I am going to use notepad.
Type - echo "hello world" in it and save it with the name (any name) firstbat.bat in 'C' drive.
Go to start -> run-> cmd
Run/Execute the batch file
Change the current directory to 'C', for that type cd c:/ of cmd and press enter. Now type 'firstbat' and press enter and you will see "hello world" on the screen.
So in short in cmd you will have to go to the directory where you have store the batch file and then type the name of the batch file.
Now, let us ask it to do something more. Open the batch file in text editor (right click -> edit). Now in the second line write - "cd c:/users" (to change the directory). Execute the batch file again you will see after echoing "hello world" your current directory will change to "c:/users".
In the coming articles we will see how we can use batch files for deploy the code.
Hope this will be of some help. Happy coding!!!
Enough said lets see how we can create one and work with it.
You can use your favorite text editor. I am going to use notepad.
Type - echo "hello world" in it and save it with the name (any name) firstbat.bat in 'C' drive.
Go to start -> run-> cmd
Run/Execute the batch file
Change the current directory to 'C', for that type cd c:/ of cmd and press enter. Now type 'firstbat' and press enter and you will see "hello world" on the screen.
So in short in cmd you will have to go to the directory where you have store the batch file and then type the name of the batch file.
Now, let us ask it to do something more. Open the batch file in text editor (right click -> edit). Now in the second line write - "cd c:/users" (to change the directory). Execute the batch file again you will see after echoing "hello world" your current directory will change to "c:/users".
In the coming articles we will see how we can use batch files for deploy the code.
Hope this will be of some help. Happy coding!!!
Comments
Post a Comment