DOS commands

What are DOS commands?

DOS commands (from Disk Operating System) are instructions that can be executed to interact with certain functions of the machine. In the early versions of MS-DOS, it was necessary to know this language in order to use the operating system. The interface was simplified in 1984 when Microsoft introduced Windows, and, while it initially simply replaced the MS-DOS interface since DOS commands were still needed for the operating system to work, these commands later became obsolete, as they were no longer necessary for the correct functioning of the system. However, they are still executable from the command line, by running a batch file or even by running certain applications.

What is a command line? What is a batch filebatch file?

The command prompt (sometimes called the command line or command processor) is located in the path C:\WINDOWS\system32\cmd.exe, which in older versions of Windows could be opened by going to Start > All programs > Accessories > Command prompt, or even more quickly by going to Start > Run and typing CMD. In the latest versions of Windows, you can search for the command prompt by searching for it in the search bar at the bottom, or by pressing Windows Key + R and typing CMD. DOS commands can be executed through this environment.

A batch filebatch file is a file (which can be created with Notepad), whose commands written inside it will be executed when the file is run through the command prompt. The extension of this type of file is .bat.

Why use DOS commands today?

Although there are very powerful tools available today and the use of CMD and batch files may seem anachronistic, DOS commands remain a simple and convenient solution to perform basic computer operations programmatically. Furthermore, these commands can also be incorporated into scripts of more advanced languages such as PowerShell. Since many DOS commands are stand-alone applications (external commands), they can also be used in environments other than the command prompt or batch file (for example, in applications, in PythonPython scripts, and so on). It is therefore a way to become familiar with the functions of the Windows operating system.

DOS commands

DOS commands are mostly applications (in .exe format), and can therefore be executed by applications external to cmd.exe. Some (including IF, DEL o ERASE, GOTO etc…) are interpreted directly by the prompt. Such commands are called internal commands, and generally cannot be executed in an environment other than the command prompt.

Special characters

Wildcards are special characters that replace one or a group of characters, usually alphanumeric (a-z, A-Z, 0-9).

  • * - Generally used for file names or extensions that you don't know, or, more frequently, to indicate a group of files or directories with the same name, extension, or to indicate all the files in a directory.

    Example: Delete all files with the .txt extension in the C:\dump directory:

    del "C:\dump\*.txt"
  • ? - Used to replace a single character when specifying a file or directory name or path.

    Example: Delete all files named brazorf with three characters as extension located in the C:\dump directory:

    del "C:\dump\brazorf.???"

Other special characters:

  • @ - Hides a command (i.e. does not display it in the prompt).

    Example: Hide the command SHUTDOWN /S /T 100 /C "Hello!":

    @shutdown /s /t 100 /c "Hello!"

    This special character can be omitted if ECHO is turned off. See ECHOECHO.

  • & - Joins two commands on the same line.

    Example: Join the command "C:\d.txt" and the command ECHO The file d.txt was opened successfully:

    "C:\d.txt" & echo The file d.txt was opened successfully

Syntax warnings

Options in square brackets [ ] may be omitted. If two or more options are inside a square bracket, this means that if one is omitted, the other must also be omitted. If the pipe symbol | is inside a square bracket, it means that you can choose between two options (or more), but you cannot select both. Commands in curly braces { } that contain the symbol |, mean that at least one option must be chosen and not more than one of those specified. Words in all-capital letters mean that they cannot be replaced (but can be omitted if inside square brackets [ ]), while words in lowercase mean that they must be replaced by a numeric or string value. Double quotes must be " " and not “ ”. The same warning applies to single quotes: ' ', not ‘ ’. The slash / can often be replaced by the hyphen -. The ellipsis ... indicates that repetition of the previous parameter is allowed (with additional information clearly specified). If the syntax is not respected, errors will be encountered, and the program execution will be interrupted.

List of DOS commands

  • ASSOCASSOC - Shows or changes applications associated with file extensions.
  • ATAT - Schedules the execution of commands or programs on a computer.
  • ATTRIBATTRIB - Displays or changes the attributes of a file.
  • BCDEDITBCDEDIT - Edits the boot configuration database and controls how the system boots.
  • BREAKBREAK - Toggles extended control of CTRL + C (^C).
  • CACLSCACLS - Shows or modifies file access control lists (ACLs).
  • CALLCALL - Calls one batch program from another.
  • CDCD - Shows the name or changes the current directory.
  • CHCPCHCP - Shows or sets the active code page number.
  • CHDIRCHDIR - Shows the name or changes the current directory.
  • CHKDSKCHKDSK - Checks a disk and displays a status report.
  • CHKNTFSCHKNTFS - Shows or modifies the verification of a disk during boot.
  • CLSCLS - Clears the screen.
  • CMDCMD - Starts a new instance of the Windows command interpreter.
  • COLORCOLOR - Sets the default foreground and background colors of the console.
  • COMPCOMP - Compares the contents of two files or a group of files.
  • COMPACTCOMPACT - Shows or changes file compression on NTFS partitions.
  • CONVERTCONVERT - Converts FAT volumes to NTFS. Cannot convert the current drive.
  • COPYCOPY - Copies one or more files to another location.
  • DATEDATE - Shows or sets the date.
  • DELDEL - Deletes one or more files.
  • DIRDIR - Displays a list of files and subdirectories in a directory.
  • DISKCOMPDISKCOMP - Compares the contents of two floppy disks.
  • DISKCOPYDISKCOPY - Copies the contents of one floppy disk to another.
  • DISKPARTDISKPART - Shows or configures disk partition properties.
  • DOSKEYDOSKEY - Edits command lines, recalls Windows commands, creates macros.
  • DRIVERQUERYDRIVERQUERY - Shows the status and properties of device drivers on a system.
  • ECHOECHO - Displays messages or turns command echo on and off.
  • ENDLOCALENDLOCAL - Ends localization of environment changes in a batch file.
  • ERASEERASE - Deletes one or more files.
  • EXITEXIT - Terminates the CMD.EXE program (the command prompt).
  • FCFC - Compares two files or groups of files and displays the differences between them.
  • FINDFIND - Searches for a text string in one or more files.
  • FINDSTRFINDSTR - Searches for strings in files.
  • FORFOR - Executes a specified command for each file in a group of files.
  • FORMATFORMAT - Formats a disk for use with Windows.
  • FSUTILFSUTIL - Shows or configures file system properties.
  • FTYPEFTYPE - Shows or changes the file types used in file extension associations.
  • GOTOGOTO - Directs the Windows command interpreter to a labeled line in a batch program.
  • GPRESULTGPRESULT - Displays Resultant Set of Policy information for the specified user or computer on a system.
  • GRAFTABLGRAFTABL - Enables Windows to display an extended character set in graphics mode.
  • HELPHELP - Provides help information for Windows commands.
  • ICACLSICACLS - Shows or modifies file access control lists (ACLs).
  • IFIF - Performs conditional processing in a batch program.
  • LABELLABEL - Creates, changes, or deletes the volume label of a disk.
  • MDMD - Creates a directory.
  • MKDIRMKDIR - Creates a directory.
  • MODEMODE - Configures a system device.
  • MORE commandMORE command - Displays output one screen at a time.
  • MOVEMOVE - Moves one or more files from one directory to another directory.
  • OPENFILESOPENFILES - Lists or disconnects open files and directories on a specified system.
  • PATHPATH - Displays or sets a search path for executable files.
  • PAUSEPAUSE - Suspends processing of a batch file and displays a message.
  • POPDPOPD - Restores the current directory to its previous value saved with PUSHD.
  • PRINTPRINT - Prints a text file.
  • PROMPTPROMPT - Changes the Windows command prompt.
  • PUSHDPUSHD - Saves the current directory and then changes it.
  • RDRD - Deletes a directory.
  • RECOVERRECOVER - Recovers readable information from a damaged or defective disk.
  • REMREM - Records comments (messages) to batch or CONFIG.SYS files.
  • RENREN - Renames files.
  • RENAMERENAME - Renames files.
  • REPLACEREPLACE - Replaces files.
  • RMDIRRMDIR - Deletes a directory.
  • ROBOCOPYROBOCOPY - Advanced tool for copying and moving files and directory trees.
  • SCSC - Manages and displays Windows services.
  • SCHTASKSSCHTASKS - Schedules the execution of commands or programs on a computer.
  • SETSET - Displays, sets, or deletes Windows environment variables.
  • SETLOCALSETLOCAL - Begins localization of environment changes in a batch file.
  • SHIFTSHIFT - Changes the position of replaceable parameters in batch files.
  • SHUTDOWNSHUTDOWN - Shuts down, restarts, hibernates, or logs off from the specified system.
  • SORTSORT - Sorts the input.
  • START commandSTART command - Launches a separate window to run a specified program or command.
  • SUBSTSUBST - Associates a path with a drive letter.
  • SYSTEMINFOSYSTEMINFO - Displays configuration information for a local or remote system, including service pack levels.
  • TASKKILLTASKKILL - Terminates a running task based on its process ID or name.
  • TASKLISTTASKLIST - Displays running tasks by process ID or name on a specified system.
  • TIMETIME - Shows or sets the system time.
  • TITLETITLE - Sets the window title for a CMD.EXE session.
  • TREETREE - Graphically displays the directory structure of a drive or path.
  • TYPETYPE - Displays the contents of a text file.
  • VERVER - Displays the Windows version.
  • VERIFYVERIFY - Tells Windows whether or not to verify that files were written correctly to a disk.
  • VOLVOL - Displays a volume label and the disk's serial number.
  • XCOPYXCOPY - Copies file and directory structures.
  • WMICWMIC - Shows information about WMI.

Comments