How to start windows cmd

Start or stop Windows service from command line (CMD)

We normally use Services.msc to start or stop or disable or enable any service. We can do the same from windows command line also using net and sc utilities. Below are commands for controlling the operation of a service.

Command to stop a service:

To start a service:

You need to have administrator privileges to run net start/stop commands. If you are just a normal user on the computer, you would get an error like below.

To disable a service:

To enable a service:

To make a service start automatically with system boot:

Note: Space is mandatory after ‘=’ in the above sc commands.

This SC command works on a Windows 7 machine and also on the down-level editions of Windows i.e Windows XP/2003 and Windows Vista. Again, if you do not have administrator previliges you would get the below error.

Note that the service name is not the display name of a service. Each service is given a unique identification name which can be used with net or sc commands. For example, Remote procedure call (RPC) is the display name of the service. But the service name we need to use in the above commands is RpcSs.
So to start Remote procedure call service the command is:

These service names are listed below for each service. The first column shows the display name of a service and the second column shows the service name that should be used in net start or net stop or sc config commands.

How to start windows cmd

Starts a new instance of the command interpreter, Cmd.exe. If used without parameters, cmd displays the version and copyright information of the operating system.

Syntax

Parameters

Parameter Description
/c Carries out the command specified by string and then stops.
/k Carries out the command specified by string and continues.
/s Modifies the treatment of string after /c or /k.
/q Turns the echo off.
/d Disables execution of AutoRun commands.
/a Formats internal command output to a pipe or a file as American National Standards Institute (ANSI).
/u Formats internal command output to a pipe or a file as Unicode.
/t: < | > Sets the background (b) and foreground (f) colors.
/e:on Enables command extensions.
/e:off Disables commands extensions.
/f:on Enables file and directory name completion.
/f:off Disables file and directory name completion.
/v:on Enables delayed environment variable expansion.
/v:off Disables delayed environment variable expansion.
Specifies the command you want to carry out.
/? Displays help at the command prompt.

The following table lists valid hexadecimal digits that you can use as the values for and :

Value Color
0 Black
1 Blue
2 Green
3 Aqua
4 Red
5 Purple
6 Yellow
7 White
8 Gray
9 Light blue
a Light green
b Light aqua
c Light red
d Light purple
e Light yellow
f Bright white

Remarks

To use multiple commands for , separate them by the command separator && and enclose them in quotation marks. For example:

If you specify /c or /k, cmd processes, the remainder of string, and the quotation marks are preserved only if all of the following conditions are met:

You don’t also use /s.

You use exactly one set of quotation marks.

You don’t use any special characters within the quotation marks (for example: & ( ) @ ^ | ).

You use one or more white-space characters within the quotation marks.

The string within quotation marks is the name of an executable file.

If the previous conditions aren’t met, string is processed by examining the first character to verify whether it is an opening quotation mark. If the first character is an opening quotation mark, it is stripped along with the closing quotation mark. Any text following the closing quotation marks is preserved.

If you don’t specify /d in string, Cmd.exe looks for the following registry subkeys:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun\REG_SZ

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun\REG_EXPAND_SZ

If one or both registry subkeys are present, they’re executed before all other variables.

Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

You can disable command extensions for a particular process by using /e:off. You can enable or disable extensions for all cmd command-line options on a computer or user session by setting the following REG_DWORD values:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD

Set the REG_DWORD value to either 0Г—1 (enabled) or 0Г—0 (disabled) in the registry by using Regedit.exe. User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.

Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

When you enable command extensions, the following commands are affected:

assoc

call

chdir (cd)

color

del (erase)

endlocal

for

ftype

goto

if

mkdir (md)

popd

prompt

pushd

set

setlocal

shift

start (also includes changes to external command processes)

If you enable delayed environment variable expansion, you can use the exclamation point character to substitute the value of an environment variable at run time.

File and directory name completion is not enabled by default. You can enable or disable file name completion for a particular process of the cmd command with /f:<on | off>. You can enable or disable file and directory name completion for all processes of the cmd command on a computer or for a user logon session by setting the following REG_DWORD values:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD

To set the REG_DWORD value, run Regedit.exe and use the hexadecimal value of a control character for a particular function (for example, 0Г—9 is TAB and 0Г—08 is BACKSPACE). User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.

Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.

If you enable file and directory name completion by using /f:on, use CTRL+D for directory name completion and CTRL+F for file name completion. To disable a particular completion character in the registry, use the value for white space [0Г—20] because it is not a valid control character.

Pressing CTRL+D or CTRL+F, processes the file and directory name completion. These key combination functions append a wildcard character to string (if one is not present), builds a list of paths that match, and then displays the first matching path.

If none of the paths match, the file and directory name completion function beeps and does not change the display. To move through the list of matching paths, press CTRL+D or CTRL+F repeatedly. To move through the list backwards, press the SHIFT key and CTRL+D or CTRL+F simultaneously. To discard the saved list of matching paths and generate a new list, edit string and press CTRL+D or CTRL+F. If you switch between CTRL+D and CTRL+F, the saved list of matching paths is discarded and a new list is generated. The only difference between the key combinations CTRL+D and CTRL+F is that CTRL+D only matches directory names and CTRL+F matches both file and directory names. If you use file and directory name completion on any of the built-in directory commands (that is, CD, MD, or RD), directory completion is assumed.

File and directory name completion correctly processes file names that contain white space or special characters if you place quotation marks around the matching path.

You must use quotation marks around the following special characters: & [ ] | < >^ = ; ! ‘ + , `

If the information that you supply contains spaces, you must use quotation marks around the text (for example, «Computer Name»).

If you process file and directory name completion from within string, any part of the path to the right of the cursor is discarded (at the point in string where the completion was processed).

start start

Запускает отдельное окно командной строки для запуска указанной программы или команды. Starts a separate Command Prompt window to run a specified program or command.

Синтаксис Syntax

Параметры Parameters

Параметр Parameter Описание Description
Задает заголовок, отображаемый в строке заголовка окна командной строки . Specifies the title to display in the Command Prompt window title bar.
/d

Указывает каталог запуска. Specifies the startup directory. /i /i Передает Cmd.exe среду запуска в новое окно командной строки . Passes the Cmd.exe startup environment to the new Command Prompt window. Если параметр /i не указан, используется текущая среда. If /i is not specified, the current environment is used. Служит для сворачивания (/min) или развертывания (/Макс) нового окна командной строки . Specifies to minimize (/min) or maximize (/max) the new Command Prompt window. Запускает 16-разрядные программы в отдельном пространстве памяти (/сепарате) или общей памяти (/Shared). Starts 16-bit programs in a separate memory space (/separate) or shared memory space (/shared). Эти параметры не поддерживаются на 64-разрядных платформах. These options are not supported on 64-bit platforms. Запускает приложение в указанном классе приоритета. Starts an application in the specified priority class. /аффинити /affinity Применяет указанную маску схожести процессоров (выраженную в виде шестнадцатеричного числа) к новому приложению. Applies the specified processor affinity mask (expressed as a hexadecimal number) to the new application. /Wait /wait Запускает приложение и ждет его завершения. Starts an application and waits for it to end. /елевате /elevate Запускает приложение от имени администратора. Runs application as administrator. /b /b Запускает приложение, не открывая новое окно командной строки . Starts an application without opening a new Command Prompt window. Обработка CTRL + C игнорируется, если приложение не поддерживает обработку CTRL + C. CTRL+C handling is ignored unless the application enables CTRL+C processing. Чтобы прервать работу приложения, используйте сочетание клавиш CTRL + BREAK. Use CTRL+BREAK to interrupt the application. [ [

. ]] Указывает запускаемую команду или программу. Specifies the command or program to start.

Указывает параметры для передачи в команду или программу. Specifies parameters to pass to either the command or the program. /? /? Отображение справки в командной строке. Displays help at the command prompt.

Комментарии Remarks

Вы можете запускать неисполняемые файлы с помощью сопоставления файлов, вводя имя файла в виде команды. You can run non-executable files through their file association by typing the name of the file as a command.

При выполнении команды, содержащей строку CMD в качестве первого маркера без квалификатора расширения или пути, команда CMD заменяется значением переменной COMSPEC. If you run a command that contains the string CMD as the first token without an extension or path qualifier, CMD is replaced with the value of the COMSPEC variable. Это не позволяет пользователям выбирать cmd из текущего каталога. This prevents users from picking up cmd from the current directory.

Если вы запускаете приложение с 32-битным графическим пользовательским интерфейсом (GUI), программа cmd не ждет завершения работы приложения, прежде чем вернуться в командную строку. If you run a 32-bit graphical user interface (GUI) application, cmd does not wait for the application to quit before returning to the command prompt. Такое поведение не происходит при запуске приложения из командного скрипта. This behavior does not occur if you run the application from a command script.

При выполнении команды, использующей первый токен, который не содержит расширение, Cmd.exe использует значение переменной среды ПАСЕКСТ, чтобы определить, какие расширения следует искать и в каком порядке. If you run a command that uses a first token that does not contain an extension, Cmd.exe uses the value of the PATHEXT environment variable to determine which extensions to look for and in what order. Значение по умолчанию для переменной ПАСЕКСТ: The default value for the PATHEXT variable is:

Обратите внимание, что синтаксис аналогичен переменной PATH с точкой с запятой (;) Отделение каждого расширения. Note that the syntax is the same as the PATH variable, with semicolons (;) separating each extension.

При поиске исполняемого файла, если нет совпадения с каким-либо расширением, запустите проверку, чтобы проверить, совпадает ли имя с именем каталога. When searching for an executable file, if there is no match on any extension, start checks to see if the name matches a directory name. Если это так, то Start открывает Explorer.exe по этому пути. If it does, start opens Explorer.exe on that path.

Примеры Examples

Чтобы запустить программу MyApp из командной строки и использовать текущее окно командной строки , введите: To start the Myapp program at the command prompt and retain use of the current Command Prompt window, type:

Чтобы просмотреть раздел справки по командной строке в отдельном окне командной строки с развернутым окном, введите: To view the start command-line help topic in a separate maximized Command Prompt window, type:

Читайте также:  Пароль для загрузок mac os
Оцените статью