Command line a. CMD commands: list, description and application. Network CMD commands. Chaining multiple commands
Take Command- offers you a new approach to working with the operating room Windows system, giving users all the power command line and ease of use with the Windows interface. Take Command supports existing CMD.EXE commands and batch files and adds thousands of new features, giving you all the power and flexibility you can imagine. Both CMD and PowerShell users will love the Take Command console with bookmarks and integration with the Windows shell.
System Requirements:
Windows® XP, 2003, Vista, Windows 7, Server 2008R2, Windows 8, Server 2012, andWindows 10, and are available in 32-bit and 64-bit versions (32/64-bit)
Torrent Windows Command Line - Take Command 01/21/48 in detail:
Take Command adds powerful features such as: online contextual help menu, plugins, collections of frequently used commands, a powerful command line editor, history recall, file name completion (even over the network), command popups and directory histories, and advanced search directories , which can be in any directory on your system: you only need to enter part of the name. Take Command expands control commands Windows files, giving you the ability to copy, move, delete or view a list of different files with a single command. You can select or exclude files from any command by date, time, size, and advanced checksums for added flexibility.
Additional information:
Batch file users will be impressed with the power and speed of adding batch files with Take Command in Windows, with an array of new batch commands. Take Command's advanced batch language includes subroutines, DO statements, IF THEN ELSE statements, SWITCH statements, error management, more than 100 internal commands, and 250 internal variables. And if you don't want to work with the program's default behavior, Take Command lets you customize your configuration using interactive dialogs or the command line. And if you want even more power, download the professional version of the program, which has FTP and HTTP support, an interactive batch troubleshooter, more than 40 additional internal commands and 130 additional internal variables and variable functions.
Program features:
·Take Command adds features such as extensive context-sensitive online help, aliases for frequently used commands, a powerful command line editor, a command history log, and an advanced directory search that can take you to any system folder by entering just part of its name.
·Take Command expands processing file Windows commands, providing the ability to copy, move, delete multiple files with one command, and also adds support for FTP and HTTP (including SSL).
·You can add or exclude files from any command, their dates, creation and modification times, size and extended mask for even more flexibility.
·By using batch files you will be amazed at the power and speed of functionality added by Take Command with many new commands, a powerful debugger, syntax highlighting, variable and editing popups.
·Unique features of the Take Command product include the ability to create an additional Windows desktop directly from the command line or from a script. And the useful RESOLUTION command helps set the display resolution, its refresh rate and, of course, color depth.
· Take Command, according to the developers, integrates many interesting tools, including an improved mechanism for network interaction and a powerful text editor based on the popular Scintilla technology. The Take Command package ensures that a wide variety of commands can be used effectively.
Treatment procedure:
Install the program, register using keygen.
This article will cover the basics team Windows strings , namely:
- Command line concept;
- Shell Commands Reference;
- Sequence of events when executing a command;
- Creating command line scripts;
- Controlling the display of text and commands;
- Commands for studying system information;
- Commands for using the registry;
- Control system services;
- Reboot and shutdown systems from the command line;
- Manage applications and processes from the command line.
Command Line Concept
Command line support is built into the operating system Microsoft system Windows and is accessible through a command shell window. The Command Prompt is supported in all versions of Windows and is used to run built-in commands, utilities, and scripts. Despite the power and flexibility of the Command Prompt, some Windows administrators never use it. If you have enough graphic tools administration, you can only apply them by clicking the user interface elements.
However, experienced Windows administrators, qualified software specialists technical support and “advanced” users cannot do without the command line. Knowing how to properly use the command line—specifically, which command line tools to choose and how and when to use them so that they work effectively—can help you avoid many problems and ensure smooth execution of your operations. If you support multiple domains or networks, understanding time-saving ways to work with the command line is not only important but necessary to automate daily operations.
With each new version The Windows command line has been improved and its capabilities expanded. The command line has undergone significant changes, associated not only with increased productivity, but also with increased flexibility. Now you can use the Windows command line to solve problems that could not be solved in previous versions Windows.
Start the Windows command shell environment in different ways, in particular by specifying parameters when starting Cmd.exe or using your own startup file stored in the directory %SystemRoot%\System32.
Additionally, the command line can be run in batch mode to execute a set of commands. In batch mode, the command line reads and executes commands one after another.
When working with the Windows command line, you need to understand where the commands you use come from. “Native” commands (built into the operating system) come in two types:
- Domestic– exist inside the command shell, they do not have separate executable files;
- External- implemented in separate executable files, which are usually stored in the %SystemRoot%\System32 directory.
Quick reference to shell commands (Cmd.exe)
- assoc- displays or modifies mappings ( associations) file types;
- break— sets breakpoints when debugging
- call— calls a procedure or another script from a script;
- cd (chdir) - shows the name of the current directory or changes the current directory;
- cls— clears the command line window and screen buffer;
- color— sets the text and background colors of the command shell window;
- sorry— copies files or performs file concatenation;
- date— shows or sets the current date;
- del (erase) — deletes a specified file, group of files, or directory;
- dir— shows a list of subdirectories and files in the current or specified directory;
- echo— displays text in the command line window or sets whether commands should be displayed on the screen (on|off);
- endlocal— marks the end of localization ( local scope) variables;
- exit— exit the command line shell;
- for— executes the given command for each file in the set;
- ftype Lists or changes current file types in file extension mappings to programs;
- goto— specifies that the command interpreter should go to the line with the given label in the batch script;
- if— executes commands according to conditions;
- md (mkdir)— creates a subdirectory in the current or specified directory;
- move— Moves a file or group of files from the current or specified source directory to the specified directory. Can also rename a directory;
- path— shows or sets the command path used operating system when searching for executable files and scripts;
- pause— stops the execution of a batch file and waits for keyboard input;
- popd— makes current the directory whose name was saved by the PUSHD command;
- prompt— specifies what text should be shown in the invitation line;
- pushd— saves the name of the current directory and, if necessary, makes the specified directory current;
- rd (rmdir)— deletes a directory or a directory along with its subdirectories;
- rem— marks comments in a batch script or Config.nt;
- ren (rename)— Renames a file or group of files;
- set— shows the current environment variables or sets temporary variables for the current command shell;
- setlocal— marks the beginning of localization ( local scope) variables in batch scripts;
- shift— shifts the position of replaced parameters in batch scripts;
- start— launches a specified program or command in a separate window;
- time— shows or sets the system time;
- title— sets the title of the command shell window;
- type— shows the contents of a text file;
- verify— turns on the file verification mode after writing to disk;
- vol— shows the label and serial number of the disk volume.
The syntax of any internal command ( and most external) can be obtained by entering the command name and /? at the command line, for example:
Command shell- a very powerful environment for working with commands and scripts. You can run commands on the command line different types: built-in commands, Windows utilities and command line versions of applications. Regardless of the type, every command you use must follow the same syntax rules. According to these rules, the command name is followed by required or optional arguments. Additionally, arguments can use input, output, or standard error redirection.
Sequence of events when executing a command
- The command shell replaces any variables entered in the command text with their current values;
- If a group or chain of several commands is entered, the line is split into individual commands, which in turn are split into the command name and arguments. Next, the commands are processed separately;
- If a command name specifies a path, the shell looks for the command in that path. If there is no such command in the specified directory, the shell returns an error;
- If the command name does not include a path, the shell first tries to resolve the command name internally. If an internal command with the same name is found, then an internal command has been called and can be executed immediately. If there is no internal command with the same name, the shell first looks for the command's executable file in the current directory, and then in the directories listed in the PATH environment variable. If the command file is not in any of these directories, the shell returns an error;
- If the command is found, it is executed with the given arguments and, if necessary, input is read from the source specified in those arguments. Command output and errors are shown in the Command Prompt window or sent to a specified output and error sink.
- As you can see, many factors affect command execution, including command paths, I/O redirection, and grouping or chaining of commands.
When working with a command shell, you probably started it by opening the Start menu ( Start) and selecting Programs ( Programs) or All Programs ( All programs), then Accessories ( Standard) and Command Prompt ( Command line). Other ways to start the command line are the Run dialog box ( Starting the program) or typing cmd in another, already open command shell window. These methods allow you to specify arguments when starting the command line: switches that control the operation of the command line, and parameters that initiate the execution of additional commands. For example, you can start a command shell in silent mode ( i.e. disable echo output) with the cmd /q command or to make the command shell execute the given command and exit - to do this, enter cmd /c, followed by the command text in quotes.
The following example starts a command shell, runs the ipconfig command, outputs the results to a file, and exits:
Cmd /c "ipconfig > c:\ipconfig.txt"
Creating Command Line Scripts
Command Line Scripts- text files with commands that you want to execute. These are the same commands that you typically enter in the Windows command shell. However, instead of typing commands every time you need them, you can script them and make your life easier.
Since scripts consist of standard text characters, they can be created and edited in any standard text editor, say, Notepad ( notebook). When entering commands, make sure that each command or group of commands that must be executed together is marked with new line. This will ensure they are executed correctly. When you've finished creating the command line script, save the script file with a .bat or .cmd extension. Both extensions work the same. For example, if you need to create a script to display the system name, Windows versions and IP configuration, include the following three commands in the SysInfo.bat or SysInfo.cmd file:
Hostname ver ipconfig -all
Controlling the display of text and commands
Team ECHO serves two purposes: to write text to output ( for example, to a command shell window or a text file) and to enable/disable command echo display. Typically, when you run script commands, the commands themselves and the output of those commands are displayed in a console window. This is called command echoing ( command echoing).
To use the ECHO command to display text, type echo followed by the text you want to display:
Echo The system host name Is: hostname
To control echoing of commands using ECHO, type echo off or echo on, for example:
Echo off echo The system host name is: hostname
To direct output to a file rather than to a shell window, use output redirection, for example:
Echo off echo The system host name is: > current.txt hostname » current.txt
Now let's see how command echoing is suppressed. Start a command shell, type echo off, then other commands. You will see that the command prompt is no longer displayed. Instead, only what is typed in the console window and the output of executed commands appears. In scripts, the ECHO OFF command disables command echoing and the command prompt. By adding the ECHO OFF command to your scripts, you prevent your shell window or file from being cluttered with command text if you are only interested in the output from those commands.
Studying system information
Often when working with a user's computer or remote server there is a need to obtain basic information about the system, such as the name of the user registered in it, the current system time, or the location of a specific file. Commands that collect basic system information include:
- NOW- displays the current system date and time in 24-hour format, for example Sal May 9 12:30:45 2003. Available only in Windows Server 2003 Resource Kit;
- WHOAMI— reports the name of the user registered in the system on at the moment, for example adatum\administrator;
- WHERE— searches for files using a search pattern ( search pattern) and returns a list of matching results.
To use NOW or WHOAMI, simply type the command in the command shell window and press Enter. The most common syntax for WHERE looks like this:
Where /r base_directory_file_name
Here the /r parameter is specified for a recursive search starting from the specified directory (base_directory) and including all its subdirectories, and file_name is the full or partial name of the file being searched, which may include wildcards: the ? replaces one character, and the * sign replaces a group of characters, for example data???.txt or data*.*. The following example searches the C:\ directory and all its subdirectories for all text files, whose names begin with data.
Where /r C:\data*.txt
You can also find files of all types whose names begin with data:
Where /r C:\data*.*
Sometimes you need to obtain information about the system configuration or the system environment. B critically important systems This information can be saved or printed for reference. Listed below are commands that allow you to collect information about the system.
- DRIVERQUERY- displays a list of all installed drivers devices and their properties, including module name, display name ( display name), driver type and build date ( driver link date). The all information display (/V) mode reports the status and state of the driver, startup mode, memory usage information, and file system path. The /V option also enables output detailed information about all unsigned drivers.
- SYSTEMINFO- issues detailed information System configuration information, including operating system version, type, manufacturer, processor, BIOS version, amount of memory, regional settings, time zone, and network adapter configuration.
- NLSINFO- Displays detailed regional information, including default language ( default language), code Windows page, time and number display formats, time zone and installed code pages. This command is only available in the Windows Server 2003 Resource Kit.
To use these commands on local computer, simply type the name of the desired command in the command shell window and press Enter.
Commands for using the registry
The Windows Registry stores configuration information for the operating system, applications, users, and hardware. This data is contained in sections ( keys) and parameters ( values) registry, which are located in a specific root section ( root key), which controls how and when sections and parameters are used.
If you know the paths to the partitions and understand the allowed data types in the partitions, you can use the command REG to view sections and parameters and manipulate them in a variety of ways. REG supports several subcommands:
- REG add— adds a new subsection or element to the registry;
- REG delete— deletes a subsection or element from the registry;
- REG query— displays a list of section elements and subsection names ( if they exist);
- REG compare— compares subsections or registry elements;
- REG I'm sorry— copies a registry element to the specified partition path on a local or remote system;
- REG restore— writes previously saved subsections, elements and parameters to the registry;
- REG save— saves a copy of the specified subkeys, elements and registry settings to a file.
System Services Management
Services provide key functions workstations and servers. To control system services on local and remote systems, use the service controller command ( service controller command) S.C., which has a set of subcommands, only part of them is described below:
- SC config— setting up accounts for registering and running services;
- SC query— displaying a list of all services configured on the computer;
- SC qc— displaying the configuration of a specific service;
- SC start— starting services;
- SC stop— stopping services;
- SC pause— suspension of services;
- SC continue— resumption of services;
- SC failure— specifying actions to be performed when a service fails;
- SC qfailure- View actions taken when a service fails.
You can specify a name in all commands remote computer, whose services you want to work with. To do this, insert the UNC name or IP address of the computer before the subcommand you are using. Here's the syntax:
Sc ServerName Subcommand
Reboot and shutdown systems from the command line
Systems often have to be rebooted or shut down. One way is to use the Shutdown utility for this, which allows you to work with local and remote systems. Another way to control system shutdown or reboot is to assign a shutdown task. Here you can use Schtasks to specify a shutdown time, or create a script with a list of shutdown commands for individual systems.
The following commands allow you to control the reboot and shutdown of the local system.
Shutting down the local system:
Shutdown /s /t Shutdown Delay /1 /f
Shutdown /r /t Shutdown Delay /1 /f
Application, process and performance management
Whenever the operating system or user runs a service, application, or command, Microsoft Windows runs one or more processes to control the associated program. Several command line utilities will make it easier for you to monitor and manage programs. These utilities include:
- Pmon (Process Resource Manager) - Shows performance statistics, including memory and CPU usage, and a list of all processes running on the local system. Allows you to receive detailed " pictures» resources involved and processes performed. Pmon comes with the Windows Resource Kit;
- Tasklist (Task List) - lists all running processes by name and process ID, reports information about the user session and occupied memory;
- Taskkill (Task Kill) - stops the execution of a process specified by name or identifier. Using filters, you can stop processes depending on their state, session number, CPU time, memory footprint, user name, and other parameters.
That's basically all I wanted to tell you about the basics of the Windows command line.
The command line is software tool input of commands by the user and receiving the results of their execution on the screen. In modern operating systems of the Windows family, the command line provides standard application cmd.exe, also called the command processor, command interpreter, and console. The Command Line application provides the user with a text interface for entering commands and obtaining the results of their execution. In fact, the command line is a software emulator of the classic console of the first computer systems, which is a terminal with a keyboard used by the operator as a means of communicating with the computer. As in the days of the first computers, the command line supports the standard input device, the keyboard, and the standard output device, the display. The user enters commands from the keyboard and receives the results of their execution on the display screen.
Launch the command line.
To launch the command line, you can use one of the following methods:
Start - Run (or Win+R keys) enter cmd and press the Enter key;
Start - All Programs - Accessories - Command Prompt";
Start - Search - Command Line . Also, to launch the command line, you can use a pre-prepared shortcut that links to the executable file %SystemRoot%\system32\cmd.exe(usually C:\Windows\system32\cmd.exe). Executing some commands requires elevated privileges, therefore, the command line application must be launched using the right-click “Run as administrator” context menu item.
Command line setup.
The standard command line window is a window with symbols white on a black background. You can change font settings, character color and background, clipboard usage, and other command line properties to suit your preferences. Settings can be made by changing the properties of the shortcut that launches the command line application, or by editing registry settings related to the command processor.Working on the command line involves entering data from the keyboard, and sometimes quite a lot of it. This volume can be significantly reduced using some techniques:
Using the clipboard.
Text selected in the application window can be copied to the clipboard, as well as pasted from the clipboard into the input field. At standard settings command line, to select text, use the “Mark” item in the right-click context menu. If desired, in the properties of the shortcut used to launch, you can enable mouse selection mode:
In mouse selection mode, context menu is not used, and the text is selected using the left mouse button. Copying and pasting is performed when clicked right button mice. When the “Allow keyboard shortcuts with CONTROL” mode is enabled, you can use standard combinations keys:
CTRL+C (CTRL+Insert) – copy selected text.
CTRL+V (Shift+Insert) – paste selected text.
Using command history and hotkeys.
To recall previously entered commands, use the arrow keys Up Arrow - one command back and Down Arrow - one command forward. In addition, you can use function keys:
F1- character-by-character call of the last entered command. Each press of F1 results in sequential substitution of one character from the previous command into the input field.
F2- copying to character. After pressing F2, the screen displays a request for the character to which the previous command will be copied. For example, if the previous command was ping yandex.ru, and a dot is specified as the symbol, then the command input line will contain ping yandex, if a space is given, then - ping.
F3- call the previous command.
F4- delete up to the character. Deletes text from the current cursor position to the specified character.
F5 And F8- calling a buffer of previously entered commands. Output by pressing the F5 key stops when the first entered command of the current session is displayed.
F7- display of previously entered commands in a separate window in the form of a list. To execute the desired command, select it using the arrow keys and press ENTER
F9- execute the command whose number is requested. The command number in the history list can be obtained by using F7.
Windows 10/Windows Server 2016 introduces features not found in previous command line implementations:
Changing the transparency of the console window when pressing combinations CTRL+Shift+- or CTRL+Shift++ .
Turn on/off full screen mode when pressed CTRL+Enter.
Expanded text selection and editing capabilities:
Shift+Home– select text from the current cursor position to the beginning of the line.
Shift+End– select text from the current cursor position to the end of the line.
Quickly move through the screen buffer and search by context:
CTRL+Home– go to the beginning of the screen buffer
CTRL+End– go to the end of the screen buffer.
CTRL+Up Arrow- move 1 line up.
CTRL+Down Arrow- move 1 line down.
CTRL+F- open the text search dialog in the screen buffer.
The command prompt window in Windows 10 can be closed using the standard keyboard shortcut - ALT+F4.
To disable new CMD features, you need to check the box “Use previous version of the console (requires restart)” in the application properties.
File path completion
In the Windows command line, you can perform file and directory name substitution when you press a key Tab. For example, to go to a directory with a long name Program Files type the initial part of the directory name
CD Pro and press Tab. The command should appear in the input line:
CD "Program Files"
As you can see, the missing part of the directory name is substituted, and in cases where it contains a space character, double quotes are also added.
If there are multiple matching initial parts of file or directory names, each time you press the key Tab the next name in alphabetical order will be substituted. To return to the previous one, use the combination Shift+Tab
Redirect console standard input/output data.
As already mentioned, as standard device The command line input is the keyboard, and the display is used as the output device. However, there is a possibility redirects I/O to other devices using redirection operators:
ping –n 5 localhost > nul- ping the loopback interface 5 times with output redirected to a dummy device nul. The output of the command execution results is suppressed. A similar technique is used to organize a delay in command files, since the ping of the loopback interface is performed almost instantly, and the interval between pings is one second, the execution time of this command is determined by the value of the parameter -n
ping –n 100 yandex.ru > C:\ping-ya.txt- ping the yandex.ru node 100 times, writing the results of the command to the file C:\ping-ya.txt. If the file does not exist, it will be created, and if it exists, its contents will be overwritten.
ping –n 100 yandex.ru >> C:\ping-ya.txt- the same as in the previous example, but if the file does not exist, then it will be created, and if it exists, then the results will be written to the end of the file.
cmd - launch the CMD command processor and enter data from the 1.txt file. If you put the line in the file ping –n 100 yandex.ru, then the command discussed above will be executed.
Often, the output of one command needs to be passed as input to another, i.e. combine commands into a sequential chain:
ping -n 100 microsoft.com | find "Interval exceeded"- result of command execution ping -n 100 microsoft.com passed as input to the string search command ( find) containing the text "Interval exceeded".
ping -n 100 microsoft.com | find "Interval exceeded" > C:\ping-ya.txt- the same as in the previous example, but with redirection of the output results of the command to a text file.
To everyone open file or the device corresponds to its own descriptor (handle) which is a non-negative number whose value is used by the process that spawned the I/O thread. By default, for all processes, including the command interpreter cmd.exe :
0 (STDIN) – standard input descriptor (keyboard input).
1 (STDOUT) – standard output descriptor (output to the screen).
2 (STDERR) – descriptor for displaying diagnostic messages (error messages on the screen).
Descriptors can be used in cases where you need to redirect (change) data sources and sinks in standard input/output streams. For example:
ping.exe –n 100 yandex.ru 2> C:\pinglog.txt- standard program message flow ping.exe will be printed to the screen and errors (stdout with handle = 2) will be written to a file C:\pinglog.txt. In the real case for the program ping.exe The above construction is not significant since it displays both diagnostics and results on the screen.
To specify redirection to existing handles, use an ampersand (&) followed by the number of the desired handle (for example, &1):
ping –n 100 yandex.ru >log.txt 2>&1- standard error messages (handle=2) are redirected to standard output (handle = 1) and the whole thing is redirected to a file log.txt current directory.
ping –n 100 yandex.ru >log.txt 1>&2- standard output (handle = 1) is redirected to error message output (handle = 2) and all this is written to a text file.
If the handle is not defined, then the input redirection operator defaults to will be zero (0), and the output redirection operator > will be one.
Chaining multiple commands
In the Windows command line, it is possible to execute several commands sequentially, depending on the results of their execution. What are command concatenation symbols used for - & (ampersand) and | (vertical bar)
& - A single ampersand is used to separate multiple commands on the same command line. For example:
echo ping ya.ru- display a line on the screen ping ya.ru
echo &ping ya.ru- sequential command execution echo without parameters and command ping ya.ru
&& - conditional execution of the second command. It will be executed if the exit code (the value of which is passed to the standard ERRORLEVEL variable) of the first command is zero, i.e. the command completed successfully.
team1 && team2- executed team1, A team2 executed only if the first one was executed successfully. For example:
ping ya.ru -err & ping –n 2 ya.ru- when using a single ampersand, the first command ping ya.ru –err -err, and the second, ping –n 2 ya.ru will ping the node twice ya.ru
ping ya.ru -err && ping –n 2 ya.ru- when using a double ampersand, the first command ping ya.ru –err will display a message about an invalid parameter -err and accordingly, will generate a termination code not equal to zero (error), which will lead to the fact that the second command ( ping ya.ru -n 2) will not be executed.
Double vertical bar || - conditional execution of the second command. If the first command completed with a non-zero return code (failure), then the command following the double vertical bar is executed.
team1 || team2- If team1 executed unsuccessfully, then it is started for execution team2
ping –n 1 ya.ru && ping –n2 ya.ru || ping –n 3 ya.ru- the 1st command will be executed first ping ya.ru –n 1- one-time node ping ya.ru, then the command will be executed ping ya.ru -n 2- double ping of the node ya.ru. Third team ping ya.ru -n 3, ping the node three times ya.ru will not be executed.
ping –n 1 –err ya.ru && ping ya.ru -n 2 || ping ya.ru -n 3- first team ping ya.ru –n 1 –err will fail due to an invalid parameter -err, second team ping –n 2 ya.ru- double ping of the node ya.ru will fail due to the double ampersand condition, and will result in the third command being executed ping –n 3 ya.ru, ping the node three times ya.ru.
In some cases, it may be necessary to prohibit the processing of service characters and treat them as plain text. For example, if you enter on the command line
ECHO
Then instead of text ping -n 1 ya.ru & ping -n 2 ya.ru the part up to the ampersand character will be displayed ping -n 1 ya.ru and then the command after the ampersand is executed - ping -n 2 ya.ru. The problem is solved by using a special escape character ^ , which allows you to use service characters as text:
ECHO ping -n 1 ya.ru ^& ping -n 2 ya.ru- text display ping -n 1 ya.ru & ping -n 2 ya.ru
Conditional command processing logic implemented using constructs && And || affects only the nearest command, that is, when entering a command
Team COPY /? will run in any case, regardless of the result of the command TYPE C:\plan.txt. However, several commands can be grouped using parentheses. For example, there are 2 command lines:
TYPE C:\plan.txt && DIR & COPY /?
TYPE C:\plan.txt && (DIR & COPY /?)
In the first of them, the conditional processing symbol && acts only on the DIR command, in the second - on two commands simultaneously: DIR and COPY. As a visual experiment, try running the second command under both file present and file absent conditions C:\plan.txt. To create an empty file, you can use copying from a dummy device nul:
copy nul C:\plan.txt
To delete a file use the command erase c:\plan.txt or del C:\plan.txt
Batch files
Batch files (scripts) are ordinary text files with a pre-prepared set of commands for execution by the command processor cmd.exe. As a standard, such files have the extension .bat or .cmd. Lines of command files can contain specific commands of the command processor itself, for example - FOR, ECHO, REM, etc. or the names of executable modules – reg.exe, sc.exe, auditpol.exe., which can be used without the extension – reg, sc, auditpol. Example of a simple batch file:
REM Creates a text file listing the Windows directory
dir C:\Windows > %TEMP%\winlist.txt
REM delay for 5 seconds
ping -n 5 localhost > nul
REM File opens in WordPad editor
write %TEMP%\winlist.txt
REM After Wordpad finishes running, the text file is deleted.
erase C:\winlist.txt
Lines starting with REM are comments. As an example, commands are used to work with file system and the graphical environment application is launched - text editor Wordpad (write.exe) passing it a command line parameter (file name). The command file language is quite primitive and does not fully meet the requirements of today, however, it is the most simple means automation of routine actions and is used by the majority system administrators and literate users. Working with batch files is a separate topic, described in more detail on the page
Hi all. In this article, we will talk about topics such as:
Command line (CMD)- This separate program, which allows the user to directly interact with the operating system. Command line based on the environment in which the applications are running and utilities using a text interface, and the execution result is displayed on the screen.
Command line Windows uses a command interpreter cmd.exe, which allows you to download applications and directs the flow of data between them, in other words, translates user commands into a form understandable to the system. Command line console integrated into all versions of Windows OS. At first glance command interface scares the user who is spoiled by the graphical interface of the same Windows, but as a rule command interface, much faster and has mass additional features, which cannot be implemented in the GUI.
Launch methods:
- Start / All Programs / Accessories / Command Prompt.
- Start / Run / enter cmd.exe in the line
- Run from the system folder: C:\WINDOWS\system32\cmd.exe
CMD commands.
Below I will give you a sign with full list command line commands, and after the tablet we will look in more detail at the main CMD commands.
Team | Description |
---|---|
ASSOC | Display or change associations based on file name extensions. |
AT | Execute commands and launch programs according to a schedule. |
ATTRIB | Display and change file attributes. |
BREAK | Enable/disable the CTRL+C key combination processing mode. |
CACLS | Display/edit access control lists (ACLs) for files. |
CALL | Calling one batch file from another. |
CD | |
CHCP | Display or set the active code page. |
CHDIR | Display the name or change the current folder. |
CHKDSK | Checking the disk and displaying statistics. |
CHKNTFS | Show or change whether disk check is performed during boot. |
CLS | Cleaning the screen. |
CMD | Launching another Windows command line interpreter. |
COLOR | Set the default text and background color. |
COMP | Comparing the contents of two files or two sets of files. |
COMPACT | Display/change file compression on NTFS partitions. |
CONVERT | Convert FAT disk volumes to NTFS. The currently active drive cannot be converted. |
COPY | Copy one or more files to another location. |
DATE | Display or set the current date. |
DEL | |
DIR | List files and subfolders from a specified folder. |
DISKCOMP | Comparing the contents of two floppy disks. |
DISKCOPY | Copying the contents of one floppy disk to another. |
DOSKEY | Editing and re-calling command lines; creating macros. |
ECHO | Display messages and switch the display mode of commands on the screen. |
ENDLOCAL | End of local environment changes for batch file. |
ERASE | Deleting one or more files. |
EXIT | Exiting the CMD.EXE (command line interpreter) program. |
F.C. | Compare two files or two sets of files and display the differences between them. |
FIND | Search for a text string in one or more files. |
FINDSTR | Searching for strings in files. |
FOR | Run the specified command for each of the files in the set. |
FORMAT | Formatting a disk for use with Windows. |
FTYPE | Display or change the file types used when matching by file name extensions. |
GOTO | Transfer control to the marked line of the batch file. |
GRAFTABL | Allows Windows to display extended characters in graphics mode. |
HELP | Displays help information about Windows commands. |
IF | An operator for conditionally executing commands in a batch file. |
LABEL | Create, change and delete volume labels for disks. |
M.D. | Creating a folder. |
MKDIR | Creating a folder. |
MODE | Configuring system devices. |
MORE | Sequential output of data in parts the size of one screen. |
MOVE | Move one or more files from one folder to another. |
PATH | Display or set the search path for executable files. |
PAUSE | Pauses the batch file and displays a message. |
POPD | Restores the previous value of the current active folder saved using the PUSHD command. |
Printing the contents of text files. | |
PROMPT | Changing the prompt in the Windows command line. |
PUSHD | Saves the current active folder and moves to another folder. |
R.D. | Deleting a folder. |
RECOVER | Recovering readable information from a bad or damaged disk. |
R.E.M. | Place comments in batch files and CONFIG.SYS file. |
REN | |
RENAME | Renaming files and folders. |
REPLACE | File replacement. |
RMDIR | Deleting a folder. |
SET | Output, installation and removal environment variables Windows. |
SETLOCAL | Start local environment changes for the batch file. |
SHIFT | Changing the contents (shift) of substituted parameters for a batch file. |
SORT | Sorting input. |
START | Run a program or command in a separate window. |
SUBST | Matches the given path to a drive name. |
TIME | Displaying and setting the system time. |
TITLE | Assigning a window title to current session command line interpreter CMD.EXE. |
TREE | Graphic display of the folder structure of a specified drive or specified folder. |
TYPE | Displaying the contents of text files. |
VER | Displays information about the Windows version. |
VERIFY | Setting the mode for checking the correctness of writing files to disk. |
VOL | Label output and serial number disk volumes. |
XCOPY | Copying files and folder trees. |
Command line commands.
Now let’s talk in more detail about the most frequently used commands, but first I’ll tell you a little about the keys that can be used together with commands for a more functional action. For example, let's take the RD command (remove directory), if it is applied to an empty folder, it will be deleted, but if there are files in the folder, then nothing will happen. So, to delete a folder along with the files in it, you need to use the key together with the RD command /s.
That is, for example, there is a directory kat and to find any files in it, in order to delete the directory along with the files, you need to register RD/s cat. A list of keys to any command can be found by typing the command name followed by a slash and the question: command_name/?.
Basic commands for working with directories:
- MD - Directory creation. Syntax: (MD directory name, it is possible to specify the location path).
- RD - Removing a directory. Syntax: (RD directory name, it is possible to specify the location path). Note, RD without keys only allows you to delete an empty directory.
- CD - Change the current directory. Syntax: (CD directory name, it is possible to specify the location path). CD\ - Go to the root directory. CD.. - Go to the parent directory.
- DIR - View directory as a list. Syntax: (DIR directory name, it is possible to specify the location path).
- TREE - Display directories in graphical representation. Syntax: (TREE directory name, it is possible to specify the location path).
- MOVE - Move\Rename directory. Syntax: .
- XCOPY - Copy directory structures. Syntax: (XCOPY what_we copy where_we copy, it is possible to specify the location path).
Commands for working with files:
- COPY CON - Create a file. Syntax: (COPY CON file_name_with_extension, it is possible to specify the location path).
- TYPE — Displays the contents of the file on the screen. Syntax: (TYPE file_name_with_extension, it is possible to specify the location path).
- DEL - Delete a file. Syntax: (DEL file_name_with_extension, it is possible to specify the location path).
- COPY - Copying a file\Combining files. Syntax(copy): (COPY what_we copy where_we copy, it is possible to specify the location path). Syntax(merging): (COPY file_name + file_name + file_name... merge_file_name, it is possible to specify the location path).
- EDIT - Create\Edit a file. Syntax: (EDIT file name, it is possible to specify the location path).
- MOVE - Move\Rename a file. Syntax: (MOVE what_we move where_we move, it is possible to specify the location path).
- REN - Rename files. Syntax: (REN what_we rename what_we rename, it is possible to specify the location path).
- FC - File comparison. (FC file_name file_name file_name..., it is possible to specify the location path).
System commands:
- CLS - Screen cleaning.
- DATE - View and display changes to the current date.
- VER — Displays information about the current version of the Operating System.
- VOL - Displays information about the volume-logical partition of the disk.
- SYSTEMINFO - Display information about system configurations.
- EXIT - Exits the command line.
These were the most used command line commands.
This is where I end this article, I hope you have fully understood the topics: CMD Commands, Command Line Commands, Command Prompt.
I recently grew from a fierce nerd in a very large company to a modest system administrator overseeing a network of 10 PCs. And, like a very lazy system administrator, I was faced with the task of automating my activities. Six months ago, I didn’t yet know that there were pipelines in the Windows command line. This was the first shocking discovery. And I went further, and it turned out that where I had previously written utilities in C#, Delphi or cumbersome scripts with nested loops, I could get by with a couple of forfiles or robocopy commands.
I won’t talk about banalities, such as listing files and folders using the Tab key. Under the hack I’ll tell you about what can be useful for novice admins and enikeys.
Hotkeys
Let's start with hotkeys, because first we need to explore what the work environment can give us.F1- In the console, this key works exactly like the right arrow, i.e. displays one character at a time from the last command entered (or selected in the history).
F2+<символ>
- Prints the last command entered up to the specified character. For example, if the last command you entered looked like this:
ping 192.168.25.1
then after pressing the key combination F2+5 you will receive:
ping 192.168.2
F3- Displays the last, and only the last, command in its entirety.
F5- Displays the last commands entered in order, just like the up arrow.
F6- Inserts the EOF character at the current command line position, which is the same as pressing Ctrl + Z.
F7- A dialog box containing the command history.
Alt+F7- Clears command history.
<символ(ы)>+ F8- Iterates through commands that begin with characters already entered into the command line.
If before pressing F8 do not enter anything, then this key will work like the up arrow, but with a slight difference - the lines will be cycled through, i.e. after the first command from the list the last one will be displayed.
F9+<число>
- Pastes a command from history under corresponding number. For example, in the situation shown in the screenshot above, when you press the combination F9+4 the following will appear in the console:
ipconfig
Command Line Operators
A long time ago, when I was little, I couldn’t even imagine how you could work in the console without GUI. After all, the output of commands sometimes takes dozens of pages, and if you need to select some data from there, then page-by-page output will not save you. But one day I installed FreeBSD on my old computer, opened the handbook and was simply dizzy with the possibilities that opened up. There you can redirect the output of a command to the input of another command and this is called a pipeline.The pipeline operator in *nix and cmd is the vertical bar character.
For example, the command will display all text files in the current folder
dir | find ".txt"
Command concatenation operator
&Example: Command1 & Command2 – Command1 will be executed first, and only then Command2
Operator AND
&&Example: Command1 && Command2 - Command2 will only be executed if Command1 succeeded
OR operator
||Example: Command1 || Command2 - Command2 will only be executed if Command1 failed to execute.
Parentheses are used to group commands, examples:
- (Command1 & Command2) && Command3 – If Command1 and Command2 are executed successfully, Command3 will be executed.
- (Team1 & Team2) || Command3 - If Command1 and Command2 are not executed, Command3 will be executed.
Thank you for your attention! I'm waiting for criticism and suggestions...
UPD1
For those who are not in the know, circumflex (that “^” sign) means pressing the Ctrl key (^C = Ctrl +C).^C - Interrupts the command, well, everyone knows that.
^S - Pauses the command and then runs it.
^I - Analogous to Tab, iterates through folders and files.
^M - Analogous to Enter.
^H - Analogous to Backspace.
^G - By writing the command echo ^G in a batch file, you can beep the system speaker (speaker).
(The commands ^I and ^H were obtained by me using the “scientific poke” method; there is also ^J but I don’t know what it does)
P.S. Other subtleties of the Windows command line have already been repeatedly covered on Habré. And I don’t see the point in copy-pasting.
P.P.S. Links to interesting posts and articles on other Windows command line features.