Windows commands
All supported versions of Windows (server and client) have a set of Win32 console commands built in.
This set of documentation describes the Windows Commands you can use to automate tasks by using scripts or scripting tools.
Prerequisites
The information that is contained in this topic applies to:
- Windows Server 2019
- Windows Server (Semi-Annual Channel)
- Windows Server 2016
- Windows Server 2012 R2
- Windows Server 2012
- Windows Server 2008 R2
- Windows Server 2008
- Windows 10
- Windows 8.1
Command shell overview
The Command shell was the first shell built into Windows to automate routine tasks, like user account management or nightly backups, with batch (.bat) files. With Windows Script Host you could run more sophisticated scripts in the Command shell. For more information, see cscript or wscript. You can perform operations more efficiently by using scripts than you can by using the user interface. Scripts accept all Commands that are available at the command line.
Windows has two command shells: The Command shell and PowerShell. Each shell is a software program that provides direct communication between you and the operating system or application, providing an environment to automate IT operations.
PowerShell was designed to extend the capabilities of the Command shell to run PowerShell commands called cmdlets. Cmdlets are similar to Windows Commands but provide a more extensible scripting language. You can run Windows Commands and PowerShell cmdlets in Powershell, but the Command shell can only run Windows Commands and not PowerShell cmdlets.
For the most robust, up-to-date Windows automation, we recommend using PowerShell instead of Windows Commands or Windows Script Host for Windows automation.
You can also download and install PowerShell Core, the open source version of PowerShell.
Incorrectly editing the registry may severely damage your system. Before making the following changes to the registry, you should back up any valued data on the computer.
To enable or disable file and directory name completion in the Command shell on a computer or user logon session, run regedit.exe and set the following reg_DWOrd value:
To set the reg_DWOrd value, 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.
Command-line reference A-Z
To find information about a specific command, in the following A-Z menu, click the letter that the command starts with, and then click the command name.
Set (переменная среды) set (environment variable)
Отображает, устанавливает или удаляет переменные среды cmd.exe. Displays, sets, or removes cmd.exe environment variables. Если используется без параметров, Set отображает текущие параметры переменной среды. If used without parameters, set displays the current environment variable settings.
Для этой команды требуются расширения команд, которые включены по умолчанию. This command requires command extensions, which are enabled by default.
Команда Set также может запускаться из консоли восстановления Windows с использованием различных параметров. The set command can also run from the Windows Recovery Console, using different parameters. Дополнительные сведения см. в разделе Среда восстановления Windows (WinRE). For more information, see Windows Recovery Environment (WinRE).
Синтаксис Syntax
Параметры Parameters
Параметр Parameter | Описание: Description |
---|---|
Задает переменную среды, которую необходимо задать или изменить. Specifies the environment variable to set or modify. | |
Указывает строку, связываемую с указанной переменной среды. Specifies the string to associate with the specified environment variable. | |
/p /p | Присваивает значение строке ввода, введенному пользователем. Sets the value of to a line of input entered by the user. |
Указывает сообщение, предлагающее пользователю ввести данные. Specifies a message to prompt the user for input. Этот параметр должен использоваться с параметром /p . This parameter must be used with the /p parameter. | |
/a /a | Задает числовое выражение, которое вычисляется. Sets to a numerical expression that is evaluated. |
Задает числовое выражение. Specifies a numerical expression. | |
/? /? | Отображение справки в командной строке. Displays help at the command prompt. |
Комментарии Remarks
Если расширения команд включены (по умолчанию) и вы запускаете Set со значением, отображаются все переменные, которые начинаются с этого значения. If command extensions are enabled (the default) and you run set with a value, it displays all of the variables that begin with that value.
Символы ,, > , | & и ^ являются специальными символами командной оболочки и перед ними должны начинаться escape-символом ( ^ ) или заключены в кавычки (например , «стрингконтаининг&Symbol»). The characters , > , | , & , and ^ are special command shell characters, and they must be preceded by the escape character ( ^ ) or enclosed in quotation marks when used in (for example, «StringContaining&Symbol»). Если строка, содержащая специальный символ, заключена в кавычки, кавычки необходимо указывать как часть значения переменной среды. If you use quotation marks to enclose a string that contains one of the special characters, the quotation marks are set as part of the environment variable value.
Используйте переменные среды для управления поведением некоторых пакетных файлов и программ, а также для управления отображением окон и подсистемы MS-DOS. Use environment variables to control the behavior of some batch files and programs and to control the way Windows and the MS-DOS subsystem appears and works. Команда Set часто используется в файле Autoexec. NT для задания переменных среды. The set command is often used in the Autoexec.nt file to set environment variables.
Если вы используете команду Set без параметров, отображаются текущие параметры среды. If you use the set command without any parameters, the current environment settings are displayed. Эти параметры обычно включают переменные среды ComSpec и path , которые используются для поиска программ на диске. These settings usually include the COMSPEC and PATH environment variables, which are used to help find programs on disk. В Windows используются две другие переменные среды: Prompt и DIRCMD. Two other environment variables used by Windows are PROMPT and DIRCMD.
Если заданы значения для и , указанное значение добавляется в среду и связывается с этой переменной. If you specify values for and , the specified value is added to the environment and is associated with that variable. Если переменная уже существует в среде, новое строковое значение заменяет старое. If the variable already exists in the environment, the new string value replaces the old string value.
Если указать только переменную и знак равенства (без ) для команды Set , значение, связанное с переменной, будет очищаться (как если бы переменная отсутствует). If you specify only a variable and an equal sign (without ) for the set command, the value associated with the variable is cleared (as if the variable is not there).
При использовании параметра /a поддерживаются следующие операторы в порядке убывания приоритета. If you use the /a parameter, the following operators are supported, in descending order of precedence:
Оператор Operator | Выполненная операция Operation performed |
---|---|
( ) | Группирование Grouping |
! — | Унарный Unary |
* / % | Арифметические Arithmetic |
+ — | Арифметические Arithmetic |
> | Логическая смена Logical shift |
& | Побитовое И Bitwise AND |
^ | Побитовое исключающее ИЛИ Bitwise exclusive OR |
= *= /= %= += -= &= ^= | = >= |
, | Разделитель выражений Expression separator |
Если используются операторы логического ( && или || ) или модуля ( % ), заключите строку выражения в кавычки. If you use logical ( && or || ) or modulus (%) operators, enclose the expression string in quotation marks. Все нечисловые строки в выражении считаются именами переменных среды, и их значения преобразуются в числа до их обработки. Any non-numeric strings in the expression are considered environment variable names, and their values are converted to numbers before they are processed. Если указать имя переменной среды, которое не определено в текущей среде, то выделяется нулевое значение, что позволяет выполнять арифметические операции со значениями переменных среды без использования% для получения значения. If you specify an environment variable name that is not defined in the current environment, a value of zero is allotted, which allows you to perform arithmetic with environment variable values without using the % to retrieve a value.
При запуске set/a из командной строки за пределами командного скрипта отображается конечное значение выражения. If you run set /a from the command line outside of a command script, it displays the final value of the expression.
Числовые значения — это десятичные числа, кроме префикса 0 × для шестнадцатеричных чисел или 0. Numeric values are decimal numbers unless prefixed by 0× for hexadecimal numbers or 0 for octal numbers. Таким образом, 0 × 12 совпадает с 18, что совпадает с 022. Therefore, 0×12 is the same as 18, which is the same as 022.
Отложенная поддержка расширения переменных среды по умолчанию отключена, но ее можно включить или отключить с помощью команды cmd/v. Delayed environment variable expansion support is disabled by default, but you can enable or disable it by using cmd /v.
При создании пакетных файлов можно использовать команду Set для создания переменных, а затем использовать их так же, как и пронумерованные переменные %0 – %9. When creating batch files, you can use set to create variables, and then use them in the same way that you would use the numbered variables %0 through %9. Можно также использовать переменные %0 – %9 в качестве входных данных для Set. You can also use the variables %0 through %9 as input for set.
При вызове значения переменной из пакетного файла заключите значение в знаки процента ( % ). If you call a variable value from a batch file, enclose the value with percent signs (%). Например, если программа пакетной службы создает переменную среды с именем бод, можно использовать строку, связанную с параметром бод , в качестве заменяемого параметра, введя % бод% в командной строке. For example, if your batch program creates an environment variable named BAUD, you can use the string associated with BAUD as a replaceable parameter by typing %baud% at the command prompt.
Примеры Examples
Чтобы задать значение Test ^ 1 для переменной среды с именем testVar , введите: To set the value TEST^1 for the environment variable named testVar , type:
Команда Set назначает значение переменной всем, что следует за знаком равенства (=). The set command assigns everything that follows the equal sign (=) to the value of the variable. Поэтому при вводе set testVar=test^1 вы получите следующий результат: testVar=test^1 . Therefore, if you type set testVar=test^1 , you’ll get the following result, testVar=test^1 .
Чтобы задать значение TEST&1 для переменной среды testVar , введите: To set the value TEST&1 for the environment variable testVar , type:
Чтобы задать переменную среды с именем include , с которой связана строка к:\директори , введите: To set an environment variable named INCLUDE so the string c:\directory is associated with it, type:
Затем можно использовать строку к:\директори в пакетных файлах, заключив имя в символы процента ( % ). You can then use the string c:\directory in batch files by enclosing the name INCLUDE with percent signs (%). Например, можно использовать dir %include% в пакетном файле для вывода содержимого каталога, связанного с переменной среды include. For example, you can use dir %include% in a batch file to display the contents of the directory associated with the INCLUDE environment variable. После обработки этой команды строка к:\директори заменяет % include%. After this command is processed, the string c:\directory replaces %include%.
Чтобы использовать команду Set в пакетной программе для добавления нового каталога в переменную среды path , введите: To use the set command in a batch program to add a new directory to the PATH environment variable, type:
Чтобы отобразить список всех переменных среды, начинающихся с буквы P, введите: To display a list of all of the environment variables that begin with the letter P, type:
A List of All Windows Shell Commands
Windows 10 has a variety of shell commands to open important folders quickly. One of the best things about Windows shell commands is that they allow you to launch deeply buried folders with a single command. For example, if you want to open the Printer devices page, you don’t have to dig through the Control Panel settings. You can just use the shell command.
I regularly use the shell commands to open all kinds of folders. Once you get used to and remember the frequently used shell commands, it is quite easy to use. Since Windows 10 has a lot of shell commands, I’ve assembled a simple list of all the shell commands you can use in Windows 10.
Use them as you need. If you want to, bookmark this page so that you can take a quick look if you ever forget your favorite Windows shell command.
Windows Shell Commands List
Below is the list all the known and useful Windows 10 Shell Commands. For ease of reading, I’ve listed them in a table format. Each and every command is very self-explanatory. For instance, shell:Start Menu will open the Start Menu folder. shell:Downloads will open your Downloads folder.
S.No | Windows Shell Command |
---|---|
1 | shell:SendTo |
2 | shell:Start Menu |
3 | shell:Startup |
4 | shell:Common Startup |
5 | shell:Recent |
6 | shell:Roaming Tiles |
7 | shell:CommonVideo |
8 | shell:OneDrivePictures |
9 | shell:PrintersFolder |
10 | shell:Common Programs |
11 | shell:Camera Roll |
12 | shell:Templates |
13 | shell:InternetFolder |
14 | shell:AppDataDocuments |
15 | shell:My Pictures |
16 | shell:UserProgramFiles |
17 | shell:PrintHood |
18 | shell:MyComputerFolder |
19 | shell:ProgramFilesX86 |
20 | shell:My Video |
21 | shell:Common Templates |
22 | shell:NetworkPlacesFolder |
23 | shell:Public |
24 | shell:NetHood |
25 | shell:AccountPictures |
26 | shell:ProgramFilesCommon |
27 | shell:SearchHistoryFolder |
28 | shell:CSCFolder |
29 | shell:Recorded Calls |
30 | shell:Local Downloads |
31 | shell:AppDataProgramData |
32 | shell:PublicLibraries |
33 | shell:ProgramFilesX64 |
34 | shell:ProgramFilesCommonX86 |
35 | shell:Administrative Tools |
36 | shell:UserProfiles |
37 | shell:PublicAccountPictures |
38 | shell:SearchTemplatesFolder |
39 | shell:ThisDeviceFolder |
40 | shell:Cookies |
41 | shell:Local Pictures |
42 | shell:ImplicitAppShortcuts |
43 | shell:VideosLibrary |
44 | shell:ResourceDir |
45 | shell:Windows |
46 | shell:Device Metadata Store |
47 | shell:ThisPCDesktopFolder |
48 | shell:Common Administrative Tools |
49 | shell:System |
50 | shell:History |
51 | shell:Personal |
52 | shell:Quick Launch |
53 | shell:Links |
54 | shell:User Pinned |
55 | shell:MusicLibrary |
56 | shell:Common Start Menu |
57 | shell:Ringtones |
58 | shell:Original Images |
59 | shell:AppDataFavorites |
60 | shell:ProgramFilesCommonX64 |
61 | shell:LocalizedResourcesDir |
62 | shell:My Music |
63 | shell:Desktop |
64 | shell:AddNewProgramsFolder |
65 | shell:CommonPictures |
66 | shell:ControlPanelFolder |
67 | shell:SavedGames |
68 | shell:Common AppData |
69 | shell:DpapiKeys |
70 | shell:SavedPictures |
71 | shell:OneDriveMusic |
72 | shell:CommonDownloads |
73 | shell:GameTasks |
74 | shell:Cache |
75 | shell:PublicGameTasks |
76 | shell:Retail Demo |
77 | shell:PhotoAlbums |
78 | shell:Common Documents |
79 | shell:ChangeRemoveProgramsFolder |
80 | shell:MAPIFolder |
81 | shell:CommonRingtones |
82 | shell:Searches |
83 | shell:Programs |
84 | shell:SystemCertificates |
85 | shell:Local Documents |
86 | shell:PicturesLibrary |
87 | shell:CryptoKeys |
88 | shell:RecordedTVLibrary |
89 | shell:Contacts |
90 | shell:Local Videos |
91 | shell:AppDataDesktop |
92 | shell:OneDrive |
93 | shell:OEM Links |
94 | shell:OneDriveDocuments |
95 | shell:HomeGroupFolder |
96 | shell:Common Start Menu Places |
97 | shell:AppMods |
98 | shell:ConflictFolder |
99 | shell:CD Burning |
100 | shell:Fonts |
101 | shell:CommonMusic |
102 | shell:Captures |
103 | shell:Development Files |
104 | shell:HomeGroupCurrentUserFolder |
105 | shell:SyncCenterFolder |
106 | shell:RecycleBinFolder |
107 | shell:3D Objects |
108 | shell:LocalAppDataLow |
109 | shell:SearchHomeFolder |
110 | shell:Application Shortcuts |
111 | shell:Downloads |
112 | shell:Favorites |
113 | shell:CameraRollLibrary |
114 | shell:Screenshots |
115 | shell:SavedPicturesLibrary |
116 | shell:Profile |
117 | shell:ConnectionsFolder |
118 | shell:Local AppData |
119 | shell:OneDriveCameraRoll |
120 | shell:ProgramFiles |
121 | shell:Common Desktop |
122 | shell:CredentialManager |
123 | shell:SyncResultsFolder |
124 | shell:AppData |
125 | shell:Libraries |
126 | shell:DocumentsLibrary |
127 | shell:SyncSetupFolder |
128 | shell:AppsFolder |
129 | shell:Roamed Tile Images |
130 | shell:UserProgramFilesCommon |
131 | shell:SystemX86 |
132 | shell:Local Music |
133 | shell:UsersFilesFolder |
134 | shell:Playlists |
135 | shell:UsersLibrariesFolder |
136 | shell:AppUpdatesFolder |
How to Use Windows Shell Commands
Using Windows shell commands is pretty easy. First, open the Run dialog box by pressing the keyboard shortcut Win + R . Next, copy the shell command of your choice, paste it in the blank field and click on the Ok button or press the Enter key on your keyboard.
As soon as you click on the Ok button, the respective folder will open in the File Explorer.
That is all. If you like this list article, do check out our other useful lists too.