DOS commands
What are DOS commands?
DOS (Disk Operating System) commands 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 even though DOS commands were necessary for the operation of the operating system, 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 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 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 Python 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 folders with the same name, extension, or to indicate all the files in a folder.Example: Delete all files with the
.txt
extension in theC:\dump
folder:del "C:\dump\*.txt"
-
?
- Used to replace a single character when specifying a file or folder name or path.Example: Delete all files named
brazorf
with three characters as extension located in theC:\dump
folder: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 ECHO. -
&
- Joins two commands on the same line.Example: Join the command
"C:\d.txt"
and the commandECHO 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
- ASSOC - Views or changes applications associated with file extensions.
- AT - Schedules the execution of commands or programs on a computer.
- ATTRIB - Displays or changes the attributes of a file.
- BCDEDIT - Edits the boot configuration database and controls how the system boots.
- BREAK - Toggles extended control of CTRL + C (^C).
- CACLS - Views or modifies file access control lists (ACLs).
- CALL - Calls one batch program from another.
- CD - Views the name or changes the current folder.
- CHCP - Views or sets the active code page number.
- CHDIR - Views the name or changes the current folder.
- CHKDSK - Checks a disk and displays a status report.
- CHKNTFS - Views or modifies the verification of a disk during boot.
- CLS - Clears the screen.
- CMD - Starts a new instance of the Windows command interpreter.
- COLOR - Sets the default foreground and background colors of the console.
- COMP - Compares the contents of two files or a group of files.
- COMPACT - Views or changes file compression on NTFS partitions.
- CONVERT - Converts FAT volumes to NTFS. Cannot convert the current drive.
- COPY - Copies one or more files to another location.
- DATE - Views or set the date.
- DEL - Deletes one or more files.
- DIR - Displays a list of files and subfolders in a folder.
- DISKCOMP - Compares the contents of two floppy disks.
- DISKCOPY - Copies the contents of one floppy disk to another.
- DISKPART - Views or configures disk partition properties.
- DOSKEY - Edist command lines, recalls Windows commands, creates macros.
- DRIVERQUERY - Views the status and properties of device drivers on a system.
- ECHO - Displays messages or turns command echo on and off.
- ENDLOCAL - Ends localization of environment changes in a batch file.
- ERASE - Deletes one or more files.
- EXIT - Terminates the CMD.EXE program (the command prompt).
- FC - Compares two files or groups of files and displays the differences between them.
- FIND - Searches for a text string in one or more files.
- FINDSTR - Searches for strings in files.
- FOR - Executes a specified command for each file in a group of files.
- FORMAT - Formats a disk for use with Windows.
- FSUTIL - Views or configures file system properties.
- FTYPE - Views or changes the file types used in file extension associations.
- GOTO - Directs the Windows command interpreter to a labeled line in a batch program.
- GPRESULT - Displays Resultant Set of Policy information for the specified user or computer on a system.
- GRAFTABL - Enables Windows to display an extended character set in graphics mode.
- HELP - Provides help information for Windows commands.
- ICACLS - Views or modifies file access control lists (ACLs).
- IF - Performs conditional processing in a batch program.
- LABEL - Creates, changes, or deletes the volume label of a disk.
- MD - Creates a folder.
- MKDIR - Creates a folder.
- MODE - Configures a system device.
- MORE command - Displays output one screen at a time.
- MOVE - Moves one or more files from one folder to another folder.
- OPENFILES - Lists or disconnects open files and folders on a specified system.
- PATH - Displays or sets a search path for executable files.
- PAUSE - Suspends processing of a batch file and displays a message.
- POPD - Restores the current folder to its previous value saved with PUSHD.
- PRINT - Prints a text file.
- PROMPT - Changes the Windows command prompt.
- PUSHD - Saves the current folder and then changes it.
- RD - Deletes a folder.
- RECOVER - Recovers readable information from a damaged or defective disk.
- REM - Records comments (messages) to batch or CONFIG.SYS files.
- REN - Renames files.
- RENAME - Renames files.
- REPLACE - Replaces files.
- RMDIR - Deletes a folder.
- ROBOCOPY - Advanced tool for copying and moving files and directory trees.
- SC - Manages and displays Windows services.
- SCHTASKS - Schedules the execution of commands or programs on a computer.
- SET - Displays, sets, or deletes Windows environment variables.
- SETLOCAL - Begins localization of environment changes in a batch file.
- SHIFT - Changes the position of replaceable parameters in batch files.
- SHUTDOWN - Shuts down, restarts, hibernates, or logs off from the specified system.
- SORT - Sorts the input.
- START command - Launches a separate window to run a specified program or command.
- SUBST - Associates a path with a drive letter.
- SYSTEMINFO - Displays configuration information for a local or remote system, including service pack levels.
- TASKKILL - Terminates a running task based on its process ID or name.
- TASKLIST - Displays running tasks by process ID or name on a specified system.
- TIME - Views or sets the system time.
- TITLE - Sets the window title for a CMD.EXE session.
- TREE - Graphically displays the folder structure of a drive or path.
- TYPE - Displays the contents of a text file.
- VER - Displays the Windows version.
- VERIFY - Tells Windows whether or not to verify that files were written correctly to a disk.
- VOL - Displays a volume label and the disk's serial number.
- XCOPY - Copies file and folder structures.
- WMIC - NEW
Commenti