How to write an address on the command line. Subtleties of working on the Windows command line. Commands for Directory Service Support

02/12/15 21.3K

Why is there such chaos in the world? Yes, because the administrator of our system forgot to fulfill his duties. Or I just lost the list of cmd commands from our world. Although this is a somewhat original look at the existing order of things, it nevertheless reflects part of the truth we need: using the command line, you can easily restore order to your computer:

What is the command line

The command line is the simplest tool for managing your computer's operating system. Control occurs using a number of reserved commands and a set of text keyboard characters without the use of a mouse ( in the Windows operating system).

On UNIX-based systems, you can use the mouse when working with the command line.

Some commands came to us from MS-DOS. The command line is also called the console. It is used not only to administer the operating system, but also to manage common programs. Most often, the most rarely used commands are included in this set of commands.

The advantage of using cmd basic commands is that it consumes a minimal amount of system resources. And this is important in case of emergency situations when all the computer’s powers are, one way or another, involved.

cmd implements the ability to execute and create entire batch files, which represent a specific order for executing a number of commands (scripts). Thanks to this, they can be used to automate certain tasks ( account management, data archiving and more).

The Windows command shell for manipulating and redirecting commands to certain operating system utilities and tools is the Cmd.exe interpreter. It loads the console and redirects commands in a format that the system understands.

Working with the command line in the Windows operating system

You can call the console in Windows in several ways:

Both methods involve running the console as the current user. That is, with all the rights and restrictions that are imposed on its role in the operating system. To run cmd with administrator rights, you need to select the program icon in the Start menu and select the appropriate item in the context menu:


After launching the utility, you can get help information about commands and the format for writing them in the console. To do this, enter the help statement and press “Enter”:

Basic commands for working with files and directories

The most frequently used commands are:

  • RENAME – renaming directories and files. Command syntax:

RENAME | REN [drive/path] original file/directory name | final filename
Example: RENAME C:UsershomeDesktoptost.txt test.txt

  • DEL (ERASE) – used to delete files only, not directories. Its syntax is:

DEL | ERASE [processing method] [filename]
Example: Del C:UsershomeDesktoptest.txt/P

By processing method we mean a special flag that allows you to implement a certain condition when deleting a file. In our example, the “P” flag enables the display of a permission dialog for deleting each file:


More information about the possible values ​​of the “processing method” parameter can be found in the technical documentation for the Windows operating system.

  • MD – allows you to create a folder at the specified path. Syntax:

MD [drive:] [path]
Example:
MD C:UsershomeDesktoptest1test2

The example will create a subfolder test2 within the test1 folder. If one of the path's root folders does not exist, it will be created too:

  • RD ( RMDIR) – deleting a specific folder or all directories at a specified path. Syntax:

RD | RMDIR [process_key] [drive/path]
Example:
rmdir /s C:UsershomeDesktoptest1test2

The example uses the s flag, which will cause the entire branch of directories specified in the path to be deleted. Therefore, you should not use the rmdir command unnecessarily with this processing key.

In the next section, we'll take a closer look at network cmd commands.

Commands for working with the network

The command line allows you to manage not only the PC file system, but also its network capabilities. The console's network commands include a large number of operators to monitor and test the network. The most relevant of them are:

  • ping – the command is used to monitor the network connection capabilities of a PC. A set number of packets are sent to the remote computer and then sent back to them. The transmission time of packets and the percentage of losses are taken into account. Syntax:

ping [-t] [-a] [-n counter] [-l size] [-f] [-i TTL] [-v type] [-r counter] [-s counter] [(-j host_list | - k node_list)] [-w interval] [target_PC_name]

Example command implementation:
ping example.microsoft.com
ping –w 10000 192.168.239.132

In the last example of the cmd ping command, the request is sent to the recipient with the specified IP address. The waiting interval between packets is 10,000 (10 seconds). By default this parameter is set to 4000:

  • tracert – used to determine the network path to a specified resource by sending a special echo message through the protocol
  • ICMP (Control Message Protocol). After running the command with parameters, a list of all routers through which the message passes is displayed. The first element in the list is the first router on the side of the requested resource.

The cmd command tracer syntax is:
tracert [-d] [-h maximum_hop_number] [-j node_list] [-w interval] [target_resource_name]
Example implementation:
tracert -d -h 10 microsoft.com

The example traces the route to a specified resource. This increases the speed of the operation due to the use of the d parameter, which prevents the command from attempting to obtain permission to read IP addresses. The number of transitions (jumps) is limited to 10 using the set value of the h parameter. By default, the number of jumps is 30:

shutdown [(-l|-s|-r|-a)] [-f] [-m [\PC_name]] [-t xx] [-c “messages”] [-d[u][p]: xx:yy]
Example:
shutdown /s /t 60 /f /l /m \191.162.1.53

The remote PC (m) with the specified IP address (191.162.1.53) will shut down (s) after 60 seconds (t). This will force you to log out of all applications (f) and the current user's session (l).

Hi all. In this article, we will talk about topics such as:

Command line (CMD) is a separate program that allows the user to directly interact with the operating system. Command line is based on an environment in which applications and utilities are executed using a text-based 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, is much faster and has a lot of additional features that cannot be implemented in a graphical interface.

Launch methods:

  1. Start / All Programs / Accessories / Command Prompt.
  2. Start / Run / enter cmd.exe in the line
  3. Run from the system folder: C:\WINDOWS\system32\cmd.exe

CMD commands.

Below I will give you a sign with a complete 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 execution of a batch file and displays a message.
POPD Restores the previous value of the current active folder saved using the PUSHD command.
PRINT 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 Listing, setting and removing Windows environment variables.
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 Assigns a window title for the current session of the CMD.EXE command line interpreter.
TREE Graphic display of the folder structure of a specified drive or specified folder.
TYPE Display 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 Displays the volume label and serial number for the disk.
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, then 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 Line.

Command line or as it is also called cmd in the Windows 8 operating system is the same as in younger versions of Windows 7, Windows Vista, Windows XP, it follows that the same commands work the same in all versions.

So let's first figure out how to launch the command line. To do this, you must have a working computer with an operating system.

Some commands, if you are running under a regular user account, may not have enough rights to execute them for security reasons, so always run the command prompt with administrator rights. There are 2 ways to launch the command line:

In the window that appears, write cmd and click OK.

A command prompt window will open with a black background.

2) A faster way: through the hot keys Win + R, here also in the window that appears we write cmd, press ok.

In Windows 8, you can only use method 2, since there is no Start menu. Let's write our first help command, which will display a list of all available commands with brief explanations.

List of all existing Windows command line commands:

ASSOC Print to screen or modify mappings based on file name extensions.
ATTRIB View and modify file properties.
BREAK Locks or unlocks enhanced CTRL+C processing in DOS.
BCDEDIT Sets properties in the boot database that allows you to control the initial boot.
CACLS Lists data and modifies access control lists (ACLs) on files.
CALL Calls one batch file from another, and can also pass input arguments.
CD
CHCP Output or set encoding.
CHDIR Displays the name or moves to another folder.
CHKDSK Diagnostics of the drive for errors.
CHKNTFS Shows or changes drive diagnostics during boot.
CLSO clearing the display of all symbols.
CMD Launches a Windows command line program. You can run an infinite number of them on one computer. They will work independently of each other.
COLOR Changes and sets the main background of the window and the fonts themselves.
COMP Shows differences and compares the contents of two files.
COMPACT Changes and shows file compression in NTFS.
CONVERT Converts FAT disk volumes to NTFS. The current drive cannot be changed.
COPY Creates a copy of a file or files and places them in the specified location.
DATE Shows or sets the current date.
DEL Destroys one or more files at once.
DIR Shows the names of files and folders with their creation date located in the current folder or specified in the folder settings.
DISKCOMP Compares and shows the differences between 2 floppy drives.
DISKCOPY Creates a copy of the contents of one floppy drive to another.
DISKPART Shows and changes the properties of a disk partition.
DOSKEY Modifies and re-invokes command lines; creates macros.
DRIVERQUERY Displays information about the status and attributes of a device driver.
ECHO Displays text information and changes the display mode of commands on the screen.
ENDLOCAL Brings the environment localization to a close for the batch file.
ERASE Destroys a file or files.
EXIT Terminates the command line program
F.C. Shows the differences between two files or two sets of files and also compares them
FIND Searches for a text string in files or in one file.
FINDSTR Advanced search for text strings in files.
FOR Cycle. Repeats execution of the same command a specified number of times
FORMAT Formatting the drive for use with Windows.
FSUTIL Shows and sets file system attributes.
FTYPE Allows you to change and view file types, which are mainly used when matching by file name extensions.
GOTO Transfers control to another specified command.
GPRESULT Displays Group Policy information for a computer or user.
GRAFTABL Allows Windows to display extended characters in graphical mode.
HELP Lists all data about existing Windows commands.
ICACLS Shows, modifies, archives, or restores ACLs for files and folders.
IF Executes commands based on a given condition.
LABEL Creates, modifies, and destroys volume labels for drives.
M.D. Creates an empty directory.
MKDIR Creates an empty directory.
MKLINK Creates symbolic and hard links
MODE Configures system devices.
MORE Sequentially displays information in blocks the size of one screen.
MOVE Moves files from one location to another.
OPENFILES Shows files that are open on a shared folder by a remote user.
PATH Displays or sets the full path to executable files.
PAUSE Stops execution of command line commands and displays information text.
POPD Restores the previous active folder value that was saved using the PUSHD command.
PRINT Prints the contents of a text file.
PROMPT Modifies the Windows command line prompt.
PUSHD Saves the active folder value and moves to another folder.
R.D. Destroys a directory.
RECOVER Revives readable data from a bad or damaged hard drive.
R.E.M. Places comments in batch files and the CONFIG.SYS file.
REN Changes the name of both files and folders.
RENAME Similar team REN.
REPLACE Swaps files.
RMDIR Destroys a directory.
ROBOCOPY Advanced tool for copying files and entire folders
SET Shows, sets, and destroys Windows environment variables.
SETLOCAL Localizes environment changes in a batch file.
S.C. Allows you to work with services
SCHTASKS Allows you to run any programs and sequentially execute the necessary commands according to a given plan
SHIFT Changes the position (shift) of substituted parameters for a batch file.
SHUTDOWN Shuts down the computer.
SORT Sorts input according to specified parameters.
START Launches a program or command in a new window.
SUBST Assigns a drive name to the specified path.
SYSTEMINFO Displays information about the operating system and computer configuration.
TASKLIST Shows a list of all running processes with their IDs.
TASKKILL“Kills” or stops the process.
TIME Sets and displays the system time.
TITLE Sets the window name for the current session of the command line interpreter CMD.EXE
TREE Displays drive directories in a convenient visual form.
TYPE Displays the contents of text files.
VER Displays brief information about the Windows version.
VERIFY Checks for file writing errors on the drive.
VOL Displays the labels and serial number of the drive volume.
XCOPY Creates a copy of files.
WMIC Prints WMI on the command line.

If your computer has the Windows operating system installed, then you can manage your system through the command line.

This is an indispensable tool that every experienced PC user uses. Thanks to the command line, you can even solve complex problems that you never thought of before.

Command line functions are a huge list of different commands that you don’t have to learn at all. In this article, we will introduce you to basic commands that may come in handy while using your computer.

We will also tell you how to launch the command line with a clear example on Windows 7.

How to use the command line?

To run this tool, you can go to Start, select the “Run” function:

After that, enter cmd in it:

That's it, the command line opens, where you can start entering various functions:

Now let's look at what commands you can enter in this window:

  • calс – to launch the calculator.
  • chkdsk is a function for checking disks for errors, to which you can add /f so that errors are automatically corrected. Example: chkdsk e: /f.
  • convert - if you need to change the file system on some storage medium without formatting it, use this function. Example: convert F: /fs:ntfs(fat32).
  • compmgmt - required to open the computer management folder, through which you can access device manager, scheduler, disk management, and so on.
  • control – to launch the control panel.
  • control admintools – to launch the Administration tool.
  • diskpart – to obtain data about the properties of a partition.
  • explorer – if icons on the desktop are no longer displayed, enter this function, it will launch Explorer.
  • fsmgmt – to launch the folder control panel.
  • format – to completely format the computer.
  • iexplore – to launch the Internet Explorer browser
  • ipconfig – for IP protocol settings.
  • msconfig – to display many of your system settings.
  • mstsc – for connecting to remote desktops.
  • netstat – to scan active connections.
  • notepad – to launch notepad.
  • osk – to launch the virtual keyboard.
  • ping – to check network response time. You can check the access of any site.
  • powercfg – for power management and energy saving.
  • regedit – to launch the registry editor.
  • sfc – to check system files. To recover damaged files, use the sfc /scannow add-on. Useful for troubleshooting virus problems.
  • shutdown – to restart the computer, use shutdown /r , you can also shut down the system using the shutdown /s add-on.

When it is not possible to use the standard interface, the command line can help out. And if a virus has infected your system and you cannot open Start, press the Win + R key combination to open the Run program from which you can open the command line.

This article will cover the basics Windows command line, 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;
  • System services management;
  • 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 Microsoft Windows operating system 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 graphical administration tools, you can only use them by clicking the user interface elements.

However, experienced Windows administrators, qualified technical support specialists 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 of Windows, the 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 of Windows.

The Windows command shell environment is launched in different ways, in particular by specifying parameters when running Cmd.exe or using its 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 by the 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 mode for checking files 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. The command line allows you to run different types of commands: 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 create a script to do so 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, be sure to start each command or group of commands that must be executed together on a 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 version, 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 a 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 currently registered in the system, 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. On mission-critical 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 device drivers and their properties, including the 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 turns on detailed information about all unsigned drivers.
  • SYSTEMINFO- Provides detailed information about the system configuration, including information about the version, type and manufacturer of the operating system, processor, BIOS version, amount of memory, regional standards, time zone, and network adapter configuration.
  • NLSINFO- Displays detailed regional information, including default language ( default language), Windows code 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 your 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 functionality for 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.

In all commands you can specify the name of the 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 starts a service, application, or command, Microsoft Windows starts one or more processes to manage 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 based on their state, session number, CPU time, memory usage, user name, and other parameters.

That's basically all I wanted to tell you about the basics of the Windows command line.