Batch Scripts or batch files is a type of scripting language made primarily for the Windows operating system. it is mostly used to automate repetitive tasks by executing a sequence of commands. They can also be used to perform system maintenance and file management.
Batch scripts consist of a series of commands written in plain text mostly using Notepad and are saved using the
.cmd file extensions.
After creating a batch file, you can run it by double-clicking on the file or using the command line to run the file. In this article, we are going to look at some of the most used Batch commands and what they do.
File and Directory Operations
|Displays or modifies file extension associations.
|Displays or changes file attributes.
|Displays or modifies access control lists (ACLs) of files.
|Copies files from one location to the other
|Deletes files only and not directories
|list the contents of a directory
|create a directory
|Remove a directory
|Advanced utility for copying files and directory trees
System Information and Configuration
|configures properties in the boot database to control boot loading.
|Analyze the disk and provide a status report
|Displays or modifies checking of disk at startup
|Open a new command prompt window
|Compares the contents of two files based on the file size.
|List the differences between two files.
|Utility for displaying/ configuring file system properties.
|Display Group Policy info for machine or user.
|Display machine properties and configuration.
|List tasks with their name and id (PID)
|Windows Management Instrumentation Command-line Utility
Script Control and Flow
|Call one batch program from another or call a subroutine
|Directs the command interpreter to a specified label within a batch script.
|Perform conditional execution in batch programs
|Set or remove a disk label
|Used to shift the position of replaceable parameters in batch files
User Interaction and Display
|Used to clear the screen
|Used to display messages in the console or turn command echoing on or off
|Display the contents of a file one screen at a time
|Pauses the execution of a batch file and then displays a message.
|Used to display or set the system time
|Set the command prompt window title
|Display the version of the operating system
|Set the default console foreground and background.
|Alters the compression of files on NTFS partitions
|Converts FAT volumes to NTFS
|Compares the contents of two disks.
|Copies the contents of one disk to another
|Display or configure disk partition properties.
|Edits command lines, recalls Windows commands and creates macros
|Displays a list of installed device drivers
|FIND / FINDSTR
|Search for strings in files.
|Configures a system device.
|Displays the files opened by a remote user for a file share.
|Print a text file.
|Changes the window command prompt.
|Used when trying to recover readable info from a defective disk.
|Used to add remarks in batch files hence they cannot be executed.
|RENAME / REN
|Rename files and directories
|Used to associate a path with a drive letter
|Verifies whether files are written correctly to a disk
|Display the label of a disk volume and serial number
|Display a tree for all subdirectories of the current directory to any level of depth.
|Print the contents of a text file.
|Provide various network services depending on the command used.
|Exits the console
|Display the list of environment variables on the current system and also set new environment variables.
Note: The functionalities and options of these commands can vary based on the Windows version used.
This list provides the most used batch commands when automating simple tasks and managing system operations. If we missed any command, please let us know and we'll be sure to add it.
Thank you for reading : )