Batch File Commands Pdf

admin
Batch File Commands Pdf Average ratng: 5,0/5 4442 votes

A batch file is a collection of MS-DOS and Windows command line commands that can be run on a computer. If you are familiar with the command line, you can use your prior knowledge to help you create a batch file. If you're new to the command line or need a refresher, see our how to use the Windows command line (DOS) page.

Batch commands

  1. Open a Command prompt window, click the upper-left corner of the Command prompt window, and then click Properties. (Or to open Command prompt Properties from the keyboard, press ALT+SPACEBAR+P.) Click the Options tab. In Command History, type or select 999 in Buffer Size, and then type or select 5 in Number of Buffers.
  2. Batch File Programming By Ankit Fadia Batch file programming is nothing but the Windows version of Unix Shell Programming. Let's start by understanding what happens when we give a DOS command. DOS is basically a file called command.com It is this file (command.com) which handles all DOS commands that you.

Below is a listing of commands used in a batch file with additional information about each of the commands.

Tip

Like all commands, all batch file commands are not case sensitive. However, we listed the batch file commands in all caps to help with identification.

Running a batch file is a simple matter of just clicking on it. Batch files can also be run in a command prompt or the Start-Run line. In such case, the full path name must be used unless the file's path is in the path environment. Following is a simple example of a batch script. This batch script when run deletes all files in the current directory. The Windows Command Line, Batch Files, and Scripting The Windows command line is a mainstay for systems administrators and power users but is relatively unknown to many PC users. The purpose of this site is to make the power and utility of the command line more familiar to a. Run Line commands. As said earlier batch file is comprised of sequence of run line commands, hence it’s a must to know at least few useful run line commands for constructing a good batch program. Here I am going to list out the useful run line commands with a brief description.

@

The at symbol does not echo back text after the symbol. The @ is most often used as @ECHO OFF to only show the output of the command.

%1

The percent followed by a numeric value, beginning with one, allows you to add matched variables to a batch file. The line below is an example of what can be used in a batch file.

With a batch file containing the above line if you type myname (name of bat file) and then your name, as shown below.

It would output 'Hello Bob' because 'Bob' is the first matched text.

Tip

You can keep going to %2, %3, etc. For example, you could use %2 for a middle name and %3 as the last name.

::

Two colons in front of any line are one of two ways of adding remarks into the batch file without displaying or executing that line when the batch file is run. Unlike REM, this line is not shown regardless if ECHO off is in the batch file.

:LABEL

By adding a colon in front of a word, such as LABEL, you create a category, more commonly known as a label. A label allows you to skip to certain sections of a batch file such as the end of the batch file. Also see GOTO.

CALL

A call is used to run another batch file within a batch file. When the batch file that is called is completed, the remainder of the original batch file is completed. If the batch file does not exist, you get an error.

CHOICE and SET

See our how to use choice and set in a batch file page for an example of how you can create options in your batch file. Further information about each of these commands can also be found on the choice and set page.

CLS

Like the DOS command would clear your screen. We find it helpful to run the cls command at the top of your batch file to clear any previous commands or output and make any output from the batch file easier to find and read.

ECHO

Echo a message in the batch file. Such as ECHO Hello World prints Hello World on the screen when executed.

Note

Without @ECHO OFF at the beginning of the batch file you'll also get 'ECHO Hello World' and 'Hello World.'

Tip

If you'd like to create a blank line, type ECHO. adding the period at the end creates an empty line.

EXIT

Exits out of the DOS window if the batch file is running from Windows. See the exit command page for further information on this command.

GOTO

Jumps to a label or section of a batch file. The goto can make it easy to jump back to the start or end of a batch file if a condition is met, or an error occurs. See our how to use choice and set in a batch file page for an example of how goto can be used.

IF

Used to check for a certain condition if the condition exists. If that condition exists, it performs that function. See the if command for further information on this command.

PAUSE

Prompt the user to press any key to continue.

REM

One of two ways of adding remarks into the batch file without displaying or executing that line when the batch file is run.

SHIFT

The shift command changes the position of replaceable parameters in a batch program. See the shift page for further information on this command.

START

Batch File Commands Pdf

Used to open Windows programs. For example, START C:WINDOWCALC would run the Windows Calculator. The start command can also be used to start any file Windows recognizes. For example, you could start a movie or audio file in a batch file to start your default player for that file.

Dos batch file commands pdfNote

In Windows 3.x, you need to utilize the WIN command. For example, WIN C:WindowsCALC.EXE would run Windows and then Calculator after Windows has finished loading.

OTHER COMMANDS

Tip

See our command line overview and our MS-DOS help page for a full listing of MS-DOS and Windows command line commands that can all be run from a batch file.

Additional information

Batch File Commands Examples Pdf

  • Batch Script Tutorial
  • Batch Script Resources

Batch File Commands Pdf Download

  • Selected Reading

In this chapter, we will look at some of the frequently used batch commands.

Batch File Commands Windows 10 Pdf

S.NoCommands & Description
1VER

This batch command shows the version of MS-DOS you are using.

2ASSOC

This is a batch command that associates an extension with a file type (FTYPE), displays existing associations, or deletes an association.

3CD

This batch command helps in making changes to a different directory, or displays the current directory.

4CLS

This batch command clears the screen.

5COPY

This batch command is used for copying files from one location to the other.

6DEL

This batch command deletes files and not directories.

7DIR

This batch command lists the contents of a directory.

8DATE

This batch command help to find the system date.

9ECHO

This batch command displays messages, or turns command echoing on or off.

10EXIT

This batch command exits the DOS console.

11MD

This batch command creates a new directory in the current location.

12MOVE

This batch command moves files or directories between directories.

13PATH

This batch command displays or sets the path variable.

14PAUSE

This batch command prompts the user and waits for a line of input to be entered.

15PROMPT

This batch command can be used to change or reset the cmd.exe prompt.

16RD

This batch command removes directories, but the directories need to be empty before they can be removed.

17REN

Renames files and directories

18REM

This batch command is used for remarks in batch files, preventing the content of the remark from being executed.

19START

This batch command starts a program in new window, or opens a document.

20TIME

This batch command sets or displays the time.

21TYPE

This batch command prints the content of a file or files to the output.

22VOL

This batch command displays the volume labels.

23ATTRIB

Displays or sets the attributes of the files in the curret directory

24CHKDSK

This batch command checks the disk for any problems.

25CHOICE

This batch command provides a list of options to the user.

26CMD

This batch command invokes another instance of command prompt.

27COMP

This batch command compares 2 files based on the file size.

28CONVERT

This batch command converts a volume from FAT16 or FAT32 file system to NTFS file system.

29DRIVERQUERY

This batch command shows all installed device drivers and their properties.

30EXPAND

This batch command extracts files from compressed .cab cabinet files.

31FIND

This batch command searches for a string in files or input, outputting matching lines.

There's so many to choose from, after all, given the console's prestigious history as the birthplace for many iconic franchises and game-changing IPs. Obscure ps2 games.

32FORMAT

This batch command formats a disk to use Windows-supported file system such as FAT, FAT32 or NTFS, thereby overwriting the previous content of the disk.

33HELP

This batch command shows the list of Windows-supplied commands.

34IPCONFIG

This batch command displays Windows IP Configuration. Shows configuration by connection and the name of that connection.

35LABEL

This batch command adds, sets or removes a disk label.

36MORE

This batch command displays the contents of a file or files, one screen at a time.

37NET

Provides various network services, depending on the command used.

38PING

This batch command sends ICMP/IP 'echo' packets over the network to the designated address.

39SHUTDOWN

This batch command shuts down a computer, or logs off the current user.

40SORT

This batch command takes the input from a source file and sorts its contents alphabetically, from A to Z or Z to A. It prints the output on the console.

41SUBST

This batch command assigns a drive letter to a local folder, displays current assignments, or removes an assignment.

42SYSTEMINFO

This batch command shows configuration of a computer and its operating system.

43TASKKILL

This batch command ends one or more tasks.

44TASKLIST

This batch command lists tasks, including task name and process id (PID).

45XCOPY

This batch command copies files and directories in a more advanced way.

46TREE

This batch command displays a tree of all subdirectories of the current directory to any level of recursion or depth.

47FC

This batch command lists the actual differences between two files.

48DISKPART

This batch command shows and configures the properties of disk partitions.

49TITLE

This batch command sets the title displayed in the console window.

50SET

Displays the list of environment variables on the current system.