Windows的CMD的NET命令net start , net stop …

微软官方文档—Net Commands On Operating Systems

在Windows安装MySQL时

  • 可以用 net start mysql 启动MySQL服务
  • 可以用 net stop mysql 停止MySQL服务

于是想想了解一下 net 命令
对比 Linux的启动停止MySQL服务

WindowsLinux
启动MySQL服务net start mysqlsystemctl start mysql
停止MySQL服务net stop mysqlsystemctl stop mysql
启用MySQL服务systemctl enable mysql
禁用MySQL服务systemctl disable mysql
重启MySQL服务systemctl restart mysql

探索 cmd 的 net
在控制台输入net

C:\Users\A>net
此命令的语法是:

NET
    [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
      HELPMSG | LOCALGROUP | PAUSE | SESSION | SHARE | START |
      STATISTICS | STOP | TIME | USE | USER | VIEW ]

输入 net help

C:\Users\A>net help
此命令的语法是:

NET HELP
command
     -或-
NET command /HELP

  可用的命令为:

  NET ACCOUNTS             NET HELPMSG              NET STATISTICS
  NET COMPUTER             NET LOCALGROUP           NET STOP
  NET CONFIG               NET PAUSE                NET TIME
  NET CONTINUE             NET SESSION              NET USE
  NET FILE                 NET SHARE                NET USER
  NET GROUP                NET START                NET VIEW
  NET HELP

  NET HELP NAMES 解释 NET HELP 语法行中的不同类型名称。
  NET HELP SERVICES 列出可以启动的一些服务。
  NET HELP SYNTAX 解释如何读取 NET HELP 语法行。
  NET HELP 命令 | MORE 显示帮助,一次显示一屏。

输入 net help start

此命令的语法是:

NET START
[service]

NET START 列出正在运行的服务。

service   可以包括以下服务之一:
   BROWSER
   DHCP CLIENT
   EVENTLOG
   FILE REPLICATION
   NETLOGON
   PLUG AND PLAY
   REMOTE ACCESS CONNECTION MANAGER
   ROUTING AND REMOTE ACCESS
   RPCSS
   SCHEDULE
   SERVER
   SPOOLER
   TCP/IP NETBIOS HELPER
   UPS
   WORKSTATION

在命令提示符处键入时,两个或更多单词的服务名称
必须括在引号中。例如,NET START "DHCP Client"
启动 DHCP Client 服务。

NET START 还可以启动非 Windows 提供的服务。

NET HELP 命令 | MORE 显示帮助,一次显示一屏。

输入net help stop

此命令的语法是:

NET STOP
service

NET STOP 停止 Windows 服务。

停止服务将取消该服务使用的任何网络连接。
此外,某些服务依赖于其他服务。停止一个
服务可能会停止其他服务。

某些服务无法停止。

service   可以是以下服务之一:
   BROWSER
   DHCP CLIENT
   FILE REPLICATION
   NETLOGON
   REMOTE ACCESS CONNECTION MANAGER
   ROUTING AND REMOTE ACCESS
   SCHEDULE
   SERVER
   SPOOLER
   TCP/IP NETBIOS HELPER
   UPS
   WORKSTATION

NET STOP 还可以停止非 Windows 提供的服务。

NET HELP 命令 | MORE 显示帮助,一次显示一屏。

net accounts: 查询账户相关信息。

net user : 查询计算机下所有的用户名。

net use: 查看当前计算机的网络连接;

微软官方文档—Net Commands On Operating Systems

Net Commands On Operating Systems
Article
09/24/2021
3 minutes to read
3 contributors

This article provides some information about Net Commands on Operating Systems.

Applies to: Windows Server 2012 R2
Original KB number: 556003

This article was written by Nirmal Sharma, Microsoft MVP.

Summary
The following knowledgebase will explain the uses of Net commands in Windows Operating Systems.

More information
Net Commands On Windows Operating Systems

The following Net Commands can be used to perform operations on Groups, users, account policies, shares, and so on.

NET
ACCOUNTS
COMPUTER
CONFIG
CONTINUE
FILE
GROUP
HELP
HELPMSG
LOCALGROUP
NAME
PAUSE
PRINT
SEND
SESSION
SHARE
START
STATISTICS
STOP
TIME
USE
USER
VIEW

The “Net Accounts” command is used to set the policy settings on local computer, such as Account policies and password policies. This command can’t be used on domain controller. This command is only used on local computer.

When you type Net Accounts, you will see the default settings of the Account Lockout policy and Password Policy in local computer show as:

Output

Copy
Force user logoff how long after time expires?: Never
Minimum password age (days): 1
Maximum password age (days): 90
Minimum password length: 8
Length of password history maintained: 5
Lockout threshold: 4
Lockout duration (minutes): 4
Lockout observation window (minutes): 4
Computer role: WORKSTATION
The above settings displayed as per the role of the computer. If computer is joined to a domain, the domain settings will take effect and only the settings coming from domain will be displayed. The rest settings will be the local settings if it’s not coming from the Domain GPO.

You can change the following use the following options in Net Accounts option:

Console

Copy
NET ACCOUNTS
[/FORCELOGOFF:{minutes | NO}]
[/MINPWLEN:length]
[/MAXPWAGE:{days | UNLIMITED}]
[/MINPWAGE:days]
[/UNIQUEPW:number] [/DOMAIN]
Two conditions are required in order for options used with NET ACCOUNTS to take effect:

/FORCELOGOFF:{minutes | NO} Sets the number of minutes a user has before being forced to log off when the account expires or valid logon hours expire. NO, the default, prevents forced logoff.

/MINPWLEN:length Sets the minimum number of characters for a password. The range is 0-14 characters; the default is six characters.

/MAXPWAGE:{days | UNLIMITED} Sets the maximum number of days that a password is valid. No limit is specified by using UNLIMITED. /MAXPWAGE can’t be less than /MINPWAGE. The range is 1-999; the default is 90 days.

/MINPWAGE:days Sets the minimum number of days that must pass before a user can change a password. A value of zero sets no minimum time. The range is 0-999; the default is zero days. /MINPWAGE can’t be more than /MAXPWAGE.\

/UNIQUEPW:number Requires that a user’s passwords be unique through the specified number of password changes. The maximum value is 24.

/DOMAIN Performs the operation on a domain controller of the current domain. Otherwise, the operation is performed on the local computer.

操作系统上的网络命令

09/24/2021
阅读时长 3 分钟
3 个贡献者

本文提供有关操作系统上的 Net 命令的一些信息。

适用于:视窗服务器 2012 R2
原始 KB 数: 556003

本文由微软MVP尼尔马尔·夏尔马撰写。

总结
以下知识库将说明网络命令在 Windows 操作系统中的用法。

更多信息
操作系统上的网络命令

以下 Net 命令可用于对组、用户、帐户策略、共享等执行操作。


帐户 计算机配置 继续 文件组 帮助 帮助MSG
本地组
名称
暂停
打印
发送
会话
共享
开始
统计信息
停止
时间
使用
用户
视图

“网络帐户”命令用于设置本地计算机上的策略设置,如帐户策略和密码策略。此命令不能在域控制器上使用。此命令仅在本地计算机上使用。

当您键入网络帐户时,您将看到本地计算机中的帐户锁定策略和密码策略的默认设置显示为:

输出

复制
Force user logoff how long after time expires?: Never
Minimum password age (days): 1
Maximum password age (days): 90
Minimum password length: 8
Length of password history maintained: 5
Lockout threshold: 4
Lockout duration (minutes): 4
Lockout observation window (minutes): 4
Computer role: WORKSTATION
上述设置根据计算机的角色显示。如果计算机已加入域,则域设置将生效,并且仅显示来自域的设置。其余设置将是本地设置(如果它不是来自域 GPO)。

您可以使用网络帐户选项中的以下选项更改以下内容:

安慰

复制
NET ACCOUNTS
[/FORCELOGOFF:{minutes | NO}]
[/MINPWLEN:length]
[/MAXPWAGE:{days | UNLIMITED}]
[/MINPWAGE:days]
[/UNIQUEPW:number] [/DOMAIN]
要使与 NET 帐户一起使用的选项生效,需要满足两个条件:

/FORCELOGOFF:{minutes | NO}设置当帐户过期或有效登录小时数过期时,用户在被强制注销之前拥有的分钟数。默认值 NO 可防止强制注销。

/MINPWLEN:length设置密码的最小字符数。范围是 0-14 个字符;默认值为六个字符。

/MAXPWAGE:{days | UNLIMITED}设置密码有效的最大天数。使用“无限制”未指定任何限制。/最大点击率不能小于 /最小水位。范围是1-999;默认值为 90 天。

/MINPWAGE:days设置用户更改密码之前必须经过的最小天数。值为零不设置最小时间。范围是 0-999;默认值为零天。/最小值不能超过 /最大最小值。

/UNIQUEPW:number要求用户的密码通过指定数量的密码更改是唯一的。最大值为 24。

/DOMAIN在当前域的域控制器上执行操作。否则,将在本地计算机上执行该操作。

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐