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 initially it simply replaced the MS-DOS interface with DOS commands operating under the hood, these commands later became obsolete for the 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 at C:\WINDOWS\system32\cmd.exe, which can be opened more quickly by going to Start > All programs > Accessories > Command Prompt, or even more quickly by going to Start > Run 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 will be executed when the file is run through the command prompt. The extension of this type of file is .bat.
DOS commands
DOS commands are mostly applications (in .exe format), and can therefore be executed by other application 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.
Wildcards
Wildcards are characters that replace one or a group of characters, usually alphanumeric (a-z, A-Z, 0-9).
* It is generally used for file names or extensions that you do not know, or, more
frequently, to indicate a group of files or directories with the same name,
extension or to indicate all files in a directory.
Example: Delete all files with the .txt extension inside the C:\dump directory:
del "C:\dump\*.txt"
Other special characters:
@ hides a command (i.e. does not display it in the command 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 disabled. See ECHO.
& joins two commands on the same line.
Example: join the command "C:\d.txt" and the command ECHO The file d.txt has been
opened correctly:
"C:\d.txt" & echo The file d.txt has been opened correctly
Syntax warnings: Options in square brackets [ ] can be omitted. If two or more options are inside a square bracket, this means that if one is omitted, the othe must also be omitted. If the symbol | is inside a square bracket, it means that you can choose between two options (or more), but you cannot choose both. Commands inside 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 indicate that they must be replaced by a numeric or string value. Double quotes must be " " and not “ ”. The same applies to single quotes: ' ', not ‘ ’. The slash / can often be replaced by the hypen -. If the syntax is not respected, errors will be encountered, and consequently the execution of the program will be interrupted. The ellipsis ... indicates that repetition of the previous parameter is allowed (specifying, of course, additional information).
ASSOC Display or change the applications associated with the file extensions.
AT Schedule the execution of commands or programs on a computer.
ATTRIB Display or change the attributes of a file.
BREAK Toggle extended control of CTRL + C (^C).
CACLS Display or modify file access control lists (ACL).
CALL Call one batch program from another.
CD Display the name or change the current directory.
CHCP Display or set the active code page number.
CHDIR Display the name or change the current directory.
CHKDSK Check a disk and display a status report.
CHKNTFS Display or modify the verification of a disk during boot.
CLS Clear the screen.
CMD Start a new instance of the Windows command interpreter.
COLOR Set the default foreground and background colors of the console.
COMP Compare the contents of two files or a group of files.
COMPACT Display or change file compression on NTFS partitions.
CONVERT Convert FAT volumes to NTFS. The current drive cannot be converted.
COPY Copy one or more files to another location.
DATE Display or set the date.
DEL Delete one or more files.
DIR Display a list of files and subdirectories in a directory.
DISKCOMP Compare the contents of two floppy disks.
DISKCOPY Copy the contents of one floppy disk to another.
DOSKEY Edit command lines, recall Windows commands, create macros.
ECHO Display messages or turn command echo on and off.
ENDLOCAL End localization of environment changes in a batch file.
ERASE Delete one or more files.
EXIT Terminate the CMD.EXE program (the command prompt).
FC Compare two files or group of files and display the differences between them.
FIND Searches for a text string in a file or files.
FINDSTR Search for strings in files.
FOR Execute a specified command for each file in a group of files.
FORMAT Format a disk for use with Windows.
FTYPE Display or change the file types used in extnesion associations of files.
GOTO Direct the Windows command interpreter to a labeled line in a batch program.
GRAFTABL Enable Windows to display an extended character set in graphic mode.
HELP Provide help information for Windows commands.
IF Perform conditional processing in a batch program.
LABEL Create, change or delete the volume label of a disk.
MD Create a directory.
MKDIR Create a directory.
MODE Configure a system device.
MORE Display output one screen at a time.
MOVE Move one or more files from one directory to another.
PATH Display or set a search path for executable files.
PAUSE Suspend processing of a batch file and display a message.
POPD Restore the current directory to its previous value saved with PUSHD.
PRINT Print a text file.
PROMPT Change the Windows command prompt.
PUSHD Save the current directory and then change it.
RD Remove a directory.
RECOVER Recover readable information from a damaged of defective disk.
REM Log comments (notes) to batch or CONFIG.SYS files.
REN Rename files.
RENAME Rename files.
REPLACE Replace files.
RMDIR Remove a directory.
SET Display, set, or delete Windows environment variables.
SETLOCAL Begin localization of environment changes in a batch file.
SHIFT Change the position of replaceable parameters in batch files.
SORT Sort the input.
START Launch a separate window to run a program or specified command.
SUBST Associate a path with a drive letter.
TIME Display or set the system time.
TITLE Set the window title for a CMD.EXE session.
TREE Graphically display the directory structure of a drive or path.
TYPE Display the contents of a text file.
VER Display the Windows version.
VERIFY Tell Windows whether or not to verify if files were written correctly
on a disk.
VOL Display a volume label and the disk serial number.
XCOPY Copy files and directory structures.