- Windows commands
- Prerequisites
- Command shell overview
- Command-line reference A-Z
- Полезные команды в консоли Windows
- Содержимое текущей папки — dir
- Открыть файл
- Перейти в другую папку — cd
- Создать папку — mkdir или md
- Удалить папку — rmdir или rd
- Показать дерево папок — tree
- Удаление файла — del или erase
- Переименование файла — ren или rename
- Команды одной строкой
- Справка по командам — help
- Command-Line Reference
- Prerequisites
- Feature description
- New and deprecated functionality
- Command shell overview
- Customize the Command Prompt window
- To configure the Command Prompt window
- Command-line reference A-Z
- Command Line Interface (CLI)
- Command line help
- Launching from command line
- Core CLI options
- Opening Files and Folders
- Working with extensions
- Advanced CLI options
- Opening VS Code with URLs
- Next steps
- Common questions
- ‘code’ is not recognized as an internal or external command
- How do I get access to a command line (terminal) from within VS Code?
- Can I specify the settings location for VS Code in order to have a portable version?
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.
Полезные команды в консоли Windows
Программистам часто приходится работать в консоли — например, чтобы запустить тестирование проекта, закоммитить новый код на Github или отредактировать документ в vim. Всё это происходит так часто, что все основные действия с файлами становится быстрее и привычнее выполнять в консоли. Рассказываем и показываем основные команды, которые помогут ускорить работу в терминале под ОС Windows.
Для начала нужно установить терминал или запустить командную строку, встроенную в Windows — для этого нажмите Win+R и введите cmd. Терминал часто встречается и прямо в редакторах кода, например, в Visual Studio Code.
Чтобы ввести команду в консоль, нужно напечатать её и нажать клавишу Enter .
Содержимое текущей папки — dir
Выводит список файлов и папок в текущей папке.
Открыть файл
Чтобы открыть файл в текущей папке, введите его полное имя с расширением. Например, blog.txt или setup.exe.
Перейти в другую папку — cd
Команда cd без аргументов выводит название текущей папки.
Перейти в папку внутри текущего каталога
Перейти на одну папку вверх
Перейти в папку на другом диске
Чтобы просто изменить диск, введите c: или d:
Создать папку — mkdir или md
Создаём пустую папку code внутри папки html :
Создаём несколько пустых вложенных папок — для этого записываем их через косую черту.
Создаётся папка css , внутри которой находится папка js . Чтобы проверить это, используем команду tree . Она показывает дерево папок.
Удалить папку — rmdir или rd
Чтобы удалить конкретную папку в текущей, введите команду rmdir .
При этом удалить можно только пустую папку. Если попытаться удалить папку, в которой что-то есть, увидим ошибку.
Чтобы удалить дерево папок, используйте ключ /s . Тогда командная строка запросит подтверждение перед тем, как удалить всё.
Показать дерево папок — tree
В любом момент мы можем увидеть структуру папок. Для этого используется команда tree .
Если вы хотите посмотреть содержимое всего диска, введите tree в корне нужного диска. Получится красивая анимация, а если файлов много, то ещё и немного медитативная.
Удаление файла — del или erase
Команда для удаления одного или нескольких файлов.
Переименование файла — ren или rename
Последовательно вводим ren, старое и новое имя файла.
Команды одной строкой
Очистить консоль — cls
Информация о системе — systeminfo
Информация о сетевых настройках — ipconfig
Список запущенных процессов — tasklist
Справка по командам — help
Команда help без аргументов выводит список всех возможных команд. help вместе с именем команды выведет справку по этой команде.
В этой статье приведены не все команды и не все их возможности, но вы всегда можете воспользоваться командой help и узнать о том, что ещё может командная строка.
Консоль — важный инструмент веб-разработчика
Научитесь пользоваться всеми инструментами в HTML Academy, чтобы работать с кодом в большой компании.
Command-Line Reference
Applies To: Windows Server 2003, Windows Vista, Windows XP, Windows Server 2008, Windows 7, Windows Server 2003 R2, Windows Server 2008 R2, Windows Server 2000, Windows Server 2012, Windows 8
Use this topic to find the documentation resources and other technical information that you need to learn about the command shell, and to automate command-line tasks by using scripts or scripting tools.
To read introductory information about the command shell and command-line tools, see Feature description. To see a listing of new and deprecated command-line tools see New and deprecated functionality.
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.
Prerequisites
The information that is contained in this overview applies to:
Windows Server 2012
WindowsВ ServerВ 2008В R2
WindowsВ ServerВ 2008
WindowsВ ServerВ 2003В R2
WindowsВ ServerВ 2003
Feature description
New and deprecated functionality
New or Deprecated?
Create a new cluster or configure an existing cluster.
Configure DFS folders and folder targets in a DFS namespace.
Creates and manages File Server Resource Manager quotas.
Create and manage file groups, file screens, file screen exceptions, and file screen templates that are used to configure general administrative options for screening files.
Enable optional features in Windows by downloading required files from WindowsВ Update or a source that Group Policy specifies.
Read, write, run, debug, and test Windows PowerShell scripts and modules in a friendly, graphic-assisted environment.
Install or remove roles, role services, and features.
Monitor an RD Session Host session.
Create and manage storage reports and storage report tasks, and configure general administrative options for File Server Resource Manager.
Command shell overview
The command shell is a software program that provides direct communication between the user and the operating system. The non-graphical, command shell user interface provides the environment in which you run character-based applications and utilities. The command shell executes programs and displays their output on the screen by using individual characters similar to the MS-DOS command interpreter, Command.com. The command shell in the Windows Server operating system uses the command interpreter, Cmd.exe. Cmd.exe loads applications, directs the flow of information between applications, and translates user input into a form that the operating system understands.
You can use the command shell to create and edit scripts to automate routine tasks. For example, you can create simple scripts in batch (.bat) files to automate the management of user accounts or nightly backups. You can also use the command-line version of Windows Script Host to 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.
Customize the Command Prompt window
You can change the properties for the Command Prompt window.
To configure the Command Prompt window
Open a Command Prompt window, click the upper-left corner of the Command Prompt window, and then click Properties. (Or to open Command Prompt Properties from the keyboard, press ALT+SPACEBAR+P.)
Click the Options tab.
In Command History, type or select 999 in Buffer Size, and then type or select 5 in Number of Buffers. By increasing the screen buffer size to 999, you enable scrolling through the Command Prompt window. By increasing the number of buffers to five, you increase the number of lines in the Command Prompt window to 5000.
In Edit Options, select the Quick Edit Mode and Insert Mode check boxes.
Click the Layout tab.
In Screen Buffer Size, type or select 2500 in Height.
To further customize your Command Prompt window settings, perform any of the following optional tasks:
In Screen Buffer Size, increase Width.
In Window Size, increase Height.
In Window Size, increase Width.
Clear the Let system position window check box, and then, in Window Position, change the values in Left and Top.
In the Apply Properties dialog box, click Save properties for future windows with same title.
To enable or disable file and directory name completion on a computer or user logon session, run Regedit.exe and set the following REG_DWORD value : HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD 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.
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.
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.
Each command-line tool topic displays the version of Windows that is supported by the command-line tool.
Command Line Interface (CLI)
Visual Studio Code has a powerful command line interface built-in that lets you control how you launch the editor. You can open files, install extensions, change the display language, and output diagnostics through command-line options (switches).
If you are looking for how to run command-line tools inside VS Code, see the Integrated Terminal.
Command line help
To get an overview of the VS Code command line interface, open a terminal or command prompt and type code —help . You will see the version, usage example, and list of command line options.
Launching from command line
You can launch VS Code from the command line to quickly open a file, folder, or project. Typically, you open VS Code within the context of a folder. To do this, from an open terminal or command prompt, navigate to your project folder and type code . :
Note: Users on macOS must first run a command (Shell Command: Install ‘code’ command in PATH) to add VS Code executable to the PATH environment variable. Read the macOS setup guide for help.
Windows and Linux installations should add the VS Code binaries location to your system path. If this isn’t the case, you can manually add the location to the Path environment variable ( $PATH on Linux). For example, on Windows, VS Code is installed under AppData\Local\Programs\Microsoft VS Code\bin . To review platform specific setup instructions, see Setup.
Insiders: If you are using the VS Code Insiders preview, you launch your Insiders build with code-insiders .
Core CLI options
Here are optional arguments you can use when starting VS Code at the command line via code :
Argument | Description |
---|---|
-h or —help | Print usage |
-v or —version | Print VS Code version (for example, 1.22.2), GitHub commit id, and architecture (for example, x64). |
-n or —new-window | Opens a new session of VS Code instead of restoring the previous session (default). |
-r or —reuse-window | Forces opening a file or folder in the last active window. |
-g or —goto | When used with file:line[:character], opens a file at a specific line and optional character position. This argument is provided since some operating systems permit : in a file name. |
-d or —diff | Open a file difference editor. Requires two file paths as arguments. |
-w or —wait | Wait for the files to be closed before returning. |
—locale | Set the display language (locale) for the VS Code session. (for example, en-US or zh-TW ) |
Opening Files and Folders
Sometimes you will want to open or create a file. If the specified file does not exist, VS Code will create them for you along with any new intermediate folders:
For both files and folders, you can use absolute or relative paths. Relative paths are relative to the current directory of the command prompt where you run code .
If you specify more than one file at the command line, VS Code will open only a single instance.
If you specify more than one folder at the command line, VS Code will create a Multi-root Workspace including each folder.
Argument | Description |
---|---|
file | Name of a file to open. If the file doesn’t exist, it will be created and marked as edited. You can specify multiple files by separating each file name with a space. |
file:line[:character] | Used with the -g argument. Name of a file to open at the specified line and optional character position. You can specify multiple files in this manner, but you must use the -g argument (once) before using the file:line[:character] specifier. |
folder | Name of a folder to open. You can specify multiple folders and a new Multi-root Workspace is created. |
Working with extensions
You can install and manage VS Code extensions from the command line.
Argument | Description |
---|---|
—install-extension | Install an extension. Provide the full extension name publisher.extension as an argument. Use —force argument to avoid prompts. |
—uninstall-extension | Uninstall an extension. Provide the full extension name publisher.extension as an argument. |
—disable-extensions | Disable all installed extensions. Extensions will still be visible in the Disabled section of the Extensions view but they will never be activated. |
—list-extensions | List the installed extensions. |
—show-versions | Show versions of installed extensions, when using —list-extensions |
—enable-proposed-api | Enables proposed api features for an extension. Provide the full extension name publisher.extension as an argument. |
Advanced CLI options
There are several CLI options that help with reproducing errors and advanced setup.
Argument | Description |
---|---|
—extensions-dir | Set the root path for extensions. Has no effect in Portable Mode. |
—user-data-dir | Specifies the directory that user data is kept in, useful when running as root. Has no effect in Portable Mode. |
-s, —status | Print process usage and diagnostics information. |
-p, —performance | Start with the Developer: Startup Performance command enabled. |
—disable-gpu | Disable GPU hardware acceleration. |
—verbose | Print verbose output (implies —wait ). |
—prof-startup | Run CPU profiler during startup. |
—upload-logs | Uploads logs from current session to a secure endpoint. |
Multi-root | |
—add | Add folder(s) to the last active window for a multi-root workspace. |
Opening VS Code with URLs
You can also open projects and files using the platform’s URL handling mechanism. Use the following URL formats to:
Open a file to line and column
You can use the URL in applications such as browsers or file explorers that can parse and redirect the URL. For example, on Windows, you could pass a vscode:// URL directly to the Windows Explorer or to the command line as start vscode://
Note: If you are using VS Code Insiders builds, the URL prefix is vscode-insiders:// .
Next steps
Read on to find out about:
- Integrated Terminal — Run command-line tools from inside VS Code.
- Basic Editing — Learn the basics of the VS Code editor.
- Code Navigation — VS Code lets you quickly understand and move through your source code.
Common questions
‘code’ is not recognized as an internal or external command
Your OS cannot find the VS Code binary code on its path. The VS Code Windows and Linux installations should have installed VS Code on your path. Try uninstalling and reinstalling VS Code. If code is still not found, consult the platform specific setup topics for Windows and Linux.
On macOS, you need to manually run the Shell Command: Install ‘code’ command in PATH command (available through the Command Palette ⇧⌘P (Windows, Linux Ctrl+Shift+P ) ). Consult the macOS specific setup topic for details.
How do I get access to a command line (terminal) from within VS Code?
VS Code has an Integrated Terminal where you can run command-line tools from within VS Code.
Can I specify the settings location for VS Code in order to have a portable version?
Not directly through the command line, but VS Code has a Portable Mode which lets you keep settings and data in the same location as your installation, for example, on a USB drive.