Windows command line commands net

.NET CLI overview

This article applies to: вњ”пёЏ .NET Core 2.1 SDK and later versions

The .NET command-line interface (CLI) is a cross-platform toolchain for developing, building, running, and publishing .NET applications.

The .NET CLI is included with the .NET SDK. To learn how to install the .NET SDK, see Install .NET Core.

CLI commands

The following commands are installed by default:

Basic commands

Project modification commands

Advanced commands

Tool management commands

  • tool install
  • tool list
  • tool update
  • tool restore Available since .NET Core SDK 3.0.
  • tool run Available since .NET Core SDK 3.0.
  • tool uninstall

Tools are console applications that are installed from NuGet packages and are invoked from the command prompt. You can write tools yourself or install tools written by third parties. Tools are also known as global tools, tool-path tools, and local tools. For more information, see .NET tools overview.

Command structure

CLI command structure consists of the driver («dotnet»), the command, and possibly command arguments and options. You see this pattern in most CLI operations, such as creating a new console app and running it from the command line as the following commands show when executed from a directory named my_app:

Driver

The driver is named dotnet and has two responsibilities, either running a framework-dependent app or executing a command.

To run a framework-dependent app, specify the app after the driver, for example, dotnet /path/to/my_app.dll . When executing the command from the folder where the app’s DLL resides, simply execute dotnet my_app.dll . If you want to use a specific version of the .NET Runtime, use the —fx-version option (see the dotnet command reference).

When you supply a command to the driver, dotnet.exe starts the CLI command execution process. For example:

First, the driver determines the version of the SDK to use. If there is no global.json file, the latest version of the SDK available is used. This might be either a preview or stable version, depending on what is latest on the machine. Once the SDK version is determined, it executes the command.

Command

The command performs an action. For example, dotnet build builds code. dotnet publish publishes code. The commands are implemented as a console application using a dotnet convention.

Arguments

The arguments you pass on the command line are the arguments to the command invoked. For example, when you execute dotnet publish my_app.csproj , the my_app.csproj argument indicates the project to publish and is passed to the publish command.

Options

The options you pass on the command line are the options to the command invoked. For example, when you execute dotnet publish —output /build_output , the —output option and its value are passed to the publish command.

Обзор интерфейса командной строки .NET .NET CLI overview

Эта статья относится к следующему. ✔️ SDK для .NET Core 2.1 и более поздних версий This article applies to: ✔️ .NET Core 2.1 SDK and later versions

Интерфейс командной строки (CLI) .NET — это кроссплатформенная цепочка инструментов для разработки, сборки, запуска и публикации приложений .NET. The .NET command-line interface (CLI) is a cross-platform toolchain for developing, building, running, and publishing .NET applications.

Интерфейс командной строки .NET входит в пакет SDK для .NET. The .NET CLI is included with the .NET SDK. Сведения об установке пакета SDK для .NET см. в статье Установка .NET Core. To learn how to install the .NET SDK, see Install .NET Core.

Читайте также:  Системные утилиты linux это

Команды CLI CLI commands

По умолчанию устанавливаются следующие команды: The following commands are installed by default:

Основные команды Basic commands

Команды для изменения проекта Project modification commands

Расширенные команды Advanced commands

Команды управления средством Tool management commands

  • tool install
  • tool list
  • tool update
  • tool restore (доступна, начиная с пакета SDK для .NET Core 3.0) tool restore Available since .NET Core SDK 3.0.
  • tool run (доступна, начиная с пакета SDK для .NET Core 3.0) tool run Available since .NET Core SDK 3.0.
  • tool uninstall

Средства — это консольные приложения, которые устанавливаются из пакетов NuGet и вызываются из командной строки. Tools are console applications that are installed from NuGet packages and are invoked from the command prompt. Вы можете писать средства самостоятельно или устанавливать средства, написанные другими. You can write tools yourself or install tools written by third parties. Средства также называются глобальными средствами, средствами пути к средству и локальными средствами. Tools are also known as global tools, tool-path tools, and local tools. Дополнительные сведения см. в обзоре средств .NET. For more information, see .NET tools overview.

Структура команд Command structure

Структура команд CLI состоит из драйвера («dotnet»), самой команды и ее возможных аргументов и параметров. CLI command structure consists of the driver («dotnet»), the command, and possibly command arguments and options. Этот шаблон используется в большинстве операций интерфейса командной строки, таких как создание консольного приложения и его запуск из командной строки, как показывают следующие команды при выполнении из каталога my_app: You see this pattern in most CLI operations, such as creating a new console app and running it from the command line as the following commands show when executed from a directory named my_app:

Драйвер Driver

Драйвер называется dotnet и имеет два вида ответственности — выполнение платформозависимого приложения или выполнение команды. The driver is named dotnet and has two responsibilities, either running a framework-dependent app or executing a command.

Для запуска платформозависимого приложения укажите его драйвера, например dotnet /path/to/my_app.dll . To run a framework-dependent app, specify the app after the driver, for example, dotnet /path/to/my_app.dll . При выполнении команды из папки, где находится библиотека DLL приложения, просто выполните dotnet my_app.dll . When executing the command from the folder where the app’s DLL resides, simply execute dotnet my_app.dll . Если вы хотите использовать конкретную версию среды выполнения .NET, используйте параметр —fx-version (см. справку по команде dotnet). If you want to use a specific version of the .NET Runtime, use the —fx-version option (see the dotnet command reference).

При указании команды для драйвера dotnet.exe запускает процесс выполнения команды CLI. When you supply a command to the driver, dotnet.exe starts the CLI command execution process. Пример: For example:

Сначала драйвер определяет нужную версию пакета SDK. First, the driver determines the version of the SDK to use. Если файл global.json отсутствует, используется последняя доступная версия пакета SDK. If there is no global.json file, the latest version of the SDK available is used. Это может быть предварительная или стабильная версия, в зависимости от того, какая версия является последней на компьютере. This might be either a preview or stable version, depending on what is latest on the machine. После определения версии пакета SDK он выполняет команду. Once the SDK version is determined, it executes the command.

Команда Command

Команда выполняет действие. The command performs an action. Например, dotnet build проводит сборку кода. For example, dotnet build builds code. dotnet publish публикует код. dotnet publish publishes code. Команды реализуются как консольное приложение с использованием соглашения dotnet . The commands are implemented as a console application using a dotnet convention.

Читайте также:  Как восстановить mmc exe windows 10

Аргументы Arguments

Аргументы, указываемые в командной строке, передаются непосредственно в вызываемую команду. The arguments you pass on the command line are the arguments to the command invoked. Например, если выполнить dotnet publish my_app.csproj , аргумент my_app.csproj указывает публикуемый проект и передается в команду publish . For example, when you execute dotnet publish my_app.csproj , the my_app.csproj argument indicates the project to publish and is passed to the publish command.

Параметры Options

Параметры, указываемые в командной строке, передаются непосредственно в вызываемую команду. The options you pass on the command line are the options to the command invoked. Например, при выполнении dotnet publish —output /build_output параметр —output и его значение передаются в команду publish . For example, when you execute dotnet publish —output /build_output , the —output option and its value are passed to the publish command.

Net Command

Use ‘net’ to manage a network from the Command Prompt in Windows

The net Command Prompt command manages almost any aspect of a network and its settings, including network shares, network print jobs, and network users.

Net Command Availability

The net command is available from within the Command Prompt in all Windows operating systems including Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP.

The availability of certain net command switches and other net command syntax may differ from operating system to operating system.

Net Command Syntax

The command takes the following general form:

Learn how to read command syntax if you’re not sure how to interpret the net command syntax shown above or described below.

The net accounts command is used to set password and logon requirements for users. For example, the net accounts command can be used to set the minimum number of characters that users can set their password to. Also supported is password expiration, minimum number of days before a user can change their password again, and the unique password count before the user can use the same old password.

Net name is used to add or delete a messaging alias at a computer. The net name command was removed in conjunction with the removal of net send beginning in Windows Vista. See the net send command for more information.

Net print is used to display and manage network print jobs. The net print command was removed beginning in Windows 7. According to Microsoft, the tasks performed with net print can be performed in Windows 10, Windows 8, and Windows 7 using the prnjobs.vbs and other cscript commands, Windows PowerShell cmdlets, or Windows Management Instrumentation (WMI).

Net send is used to send messages to other users, computers, or net name created messaging aliases. The net send command is not available in Windows 10, Windows 8, Windows 7, or Windows Vista but the msg command accomplishes the same thing.

The net use command is used to display information about shared resources on the network that you’re currently connected to, as well as connect to new resources and disconnect from connected ones.

In other words, the net use command can be used to show the shared drives you’ve mapped to as well as allow you to manage those mapped drives.

The net helpmsg is used to display more information about the numerical network messages you might receive when using net commands. For example, when executing net group on a standard Windows workstation, you’ll receive a 3515 help message. To decode this message, type net helpmsg 3515 which displays «This command can be used only on a Windows Domain Controller.» on screen.

Net Command Options
Option Explanation
net Execute the net command alone to show information about how to use the command which, in this case, is simply a list of the net subset commands.
accounts
computer The net computer command is used to add or remove a computer from a domain.
config Use the net config command to show information about the configuration of the Server or Workstation service.
continue The net continue command is used to restart a service that was put on hold by the net pause command.
file Net file is used to show a list of open files on a server. The command can also be used to close a shared file and remove a file lock.
group The net group command is used to add, delete, and manage global groups on servers.
localgroup The net localgroup command is used to add, delete, and manage local groups on computers.
name
pause The net pause command puts on hold a Windows resource or service.
print
session The net session command is used to list or disconnect sessions between the computer and others on the network.
share The net share command is used to create, remove, and otherwise manage shared resources on the computer.
start The net start command is used to start a network service or list running network services.
statistics Use the net statistics command to show the network statistics log for the Server or Workstation service.
stop The net stop command is used to stop a network service.
time Net time can be used to display the current time and date of another computer on the network.
use
user The net user command is used to add, delete, and otherwise manage the users on a computer.
view Net view is used to show a list of computers and network devices on the network.
helpmsg
/? Use the help switch with the net command to show detailed help about the command’s several options.

Save to a file whatever a net command shows on screen using a redirection operator with the command. Learn how to redirect command output to a file or see our list of command prompt tricks for more tips.

Only in Windows NT and Windows 2000 was there a difference in the net command and the net1 command. The net1 command was made available in these two operating systems as a temporary fix for a Y2K problem that affected the net command.

Net Command Examples

This is one of the simplest net commands that lists all the networked devices.

In the above example, I’m sharing the Z:\Downloads folder with everyone on the network and giving all of them full read/write access. You could modify this one by replacing FULL with READ or CHANGE for those rights only, as well as replace everyone with a specific username to give share access to just that one user account.

This example of the net accounts command forces a user’s password to expire after 180 days. This number can be anywhere from 1 to 49,710, or UNLIMITED can be used so that the password never expires. Default is 90 days.

The above net command example is how you’d stop the Print Spooler service from the command line. Services can also be started, stopped, and restarted via the Services graphical tool in Windows (services.msc), but using the net stop command lets you control them from places like Command Prompt and BAT files.

Executing the net start command without any options following it (e.g. net start «print spooler») is useful if you want to see a list of currently running services. This list can be helpful when managing services because you don’t have to leave the command line to see which services are running.

The net commands are network-related commands and so may often be used for troubleshooting or management alongside commands like ping, tracert, ipconfig, netstat, nslookup, and others.

Читайте также:  Room correction что это windows
Оцените статью