About this Tutorial
About this Tutorial
Batch scripts are stored in simple text files containing lines with commands that get
executed in sequence, one after the other. Scripting is a way by which one can alleviate
this necessity by automating these command sequences in order to make one¡¯s life at the
shell easier and more productive.
This tutorial discusses the basic functionalities of batch scripting along with relevant
examples for easy understanding.
Audience
This tutorial has been prepared for beginners to understand the basic concepts of batch
scripting.
Prerequisites
A reasonable knowledge of computer programming and concepts such as variables,
commands, syntax, etc. is desired.
Copyright & Disclaimer
? Copyright 2016 by Tutorials Point (I) Pvt. Ltd.
All the content and graphics published in this e-book are the property of Tutorials Point (I)
Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish
any contents or a part of contents of this e-book in any manner without written consent
of the publisher.
We strive to update the contents of our website and tutorials as timely and as precisely as
possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt.
Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our
website or its contents including this tutorial. If you discover any errors on our website or
in this tutorial, please notify us at contact@
i
Table of Contents
About this Tutorial ................................................................................................................................... i
Audience .................................................................................................................................................. i
Prerequisites ............................................................................................................................................ i
Copyright & Disclaimer ............................................................................................................................. i
Table of Contents .................................................................................................................................... ii
1.
BATCH SCRIPTING ¨C OVERVIEW........................................................................................... 1
2.
BATCH SCRIPTING ¨C ENVIRONMENT.................................................................................... 2
Writing and Executing ............................................................................................................................. 2
Environment Variables ............................................................................................................................ 4
3.
BATCH SCRIPTING ¨C COMMANDS ........................................................................................ 5
ver ........................................................................................................................................................... 5
ASSOC ..................................................................................................................................................... 5
CD ........................................................................................................................................................... 6
CLS .......................................................................................................................................................... 7
Copy ........................................................................................................................................................ 7
DEL .......................................................................................................................................................... 8
DIR .......................................................................................................................................................... 9
DATE ....................................................................................................................................................... 9
ECHO ..................................................................................................................................................... 10
EXIT ....................................................................................................................................................... 11
MD ........................................................................................................................................................ 11
MOVE .................................................................................................................................................... 12
PATH ..................................................................................................................................................... 12
PAUSE ................................................................................................................................................... 13
PROMPT ................................................................................................................................................ 13
ii
RD ......................................................................................................................................................... 14
REN ....................................................................................................................................................... 14
REM ...................................................................................................................................................... 15
START .................................................................................................................................................... 15
TIME ...................................................................................................................................................... 15
TYPE ...................................................................................................................................................... 16
VOL ....................................................................................................................................................... 16
ATTRIB .................................................................................................................................................. 17
CHKDSK ................................................................................................................................................. 18
CHOICE .................................................................................................................................................. 18
CMD ...................................................................................................................................................... 19
COMP .................................................................................................................................................... 19
CONVERT............................................................................................................................................... 19
DRIVERQUERY ....................................................................................................................................... 20
EXPAND................................................................................................................................................. 21
FIND ...................................................................................................................................................... 21
FORMAT ................................................................................................................................................ 21
HELP ...................................................................................................................................................... 22
IPCONFIG .............................................................................................................................................. 23
LABEL .................................................................................................................................................... 24
MORE .................................................................................................................................................... 24
NET ....................................................................................................................................................... 25
PING ...................................................................................................................................................... 26
SHUTDOWN .......................................................................................................................................... 27
SORT ..................................................................................................................................................... 28
SUBST .................................................................................................................................................... 28
SYSTEMINFO ......................................................................................................................................... 28
iii
TASKKILL ............................................................................................................................................... 29
TASKLIST ............................................................................................................................................... 29
XCOPY ................................................................................................................................................... 30
TREE ...................................................................................................................................................... 30
FC .......................................................................................................................................................... 31
DISKPART .............................................................................................................................................. 31
TITLE ..................................................................................................................................................... 32
SET ........................................................................................................................................................ 32
4.
BATCH SCRIPTING ¨C FILES .................................................................................................. 33
Creating Batch Files ............................................................................................................................... 33
Saving Batch Files .................................................................................................................................. 33
Executing Batch Files ............................................................................................................................. 34
Modifying Batch Files ............................................................................................................................ 35
5.
BATCH SCRIPTING ¨C SYNTAX.............................................................................................. 36
6.
BATCH SCRIPTING ¨C VARIABLES ......................................................................................... 37
Command Line Arguments .................................................................................................................... 37
Set Command ........................................................................................................................................ 38
Working with Numeric Values ............................................................................................................... 38
Local vs Global Variables ....................................................................................................................... 39
Working with Environment Variables .................................................................................................... 40
7.
BATCH SCRIPTING ¨C COMMENTS....................................................................................... 41
Comments Using the Rem Statement .................................................................................................... 41
Comments Using the :: Statement ......................................................................................................... 42
8.
BATCH SCRIPTING ¨C STRINGS ............................................................................................ 44
Create String ......................................................................................................................................... 44
Empty String.......................................................................................................................................... 44
iv
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- ms dos command examples
- windows 10 dos commands list
- learning ms dos basics a tutorial university of north carolina
- 092 2008 check out these pipes using microsoft windows commands sas
- dos disk operating system
- ms dos commands list pdf weebly
- command prompt cheatsheet columbia university
- command line ip utilities guide to tcp ip
- dos commands for hacking 134 209 106 255
- windows 10 cmd commands cheat sheet pdf weebly
Related searches
- this year s or this years
- free excel tutorial download pdf
- printable excel tutorial in pdf
- microsoft excel tutorial pdf download
- ms excel 2013 tutorial pdf
- free basic excel tutorial pdf
- this is he vs this is him
- about this topic
- this years or this year s grammar
- this years or this year s
- this year s vs this years
- what interest you about this position answer