Windows CMD.exe或带有示例的Command Shell教程
Windows cmd
or cmd.exe
is standard shell and command line interface for all of the Windows operating system. Currently Powershell is preferred one but cmd
is useful and popular too. In this tutorial we will look some features of the cmd.exe
aka cmd
Windows cmd
或cmd.exe
是所有Windows操作系统的标准外壳程序和命令行界面。 当前,Powershell是首选,但cmd
很有用,也很流行。 在本教程中,我们将查找cmd.exe
某些功能,也称为cmd
打开命令行外壳 (Open Command Line Shell)
We can open command shell or cmd
in different ways. We can open it from Program Files. But the most practical way is opening with Run
prompt. We will write cmd
to the run and hit enter.
我们可以通过不同的方式打开命令shell或cmd
。 我们可以从程序文件中打开它。 但是最实用的方法是使用Run
提示打开。 我们将cmd
写入运行,然后按Enter。
cmd
运行并关闭Cmd (Run and Close Cmd)
We can provide the command we want to run in cmd shell environment with /C
option. We will also specify the command we want to run.
我们可以使用/C
选项提供要在cmd shell环境中运行的命令。 我们还将指定我们要运行的命令。
In this example we will run dir
command and then close cmd
在此示例中,我们将运行dir
命令,然后关闭cmd
> cmd /C dir
If we want to see the close effect we can run this command in run
如果要查看关闭效果,可以在run
运行此命令
运行并返回Cmd(Run and Return Cmd)
If we need to run command in a new cmd shell and then do not close the cmd in order to see command output we can run /K
option.
如果我们需要在新的cmd shell中运行命令,然后不关闭cmd以查看命令输出,则可以运行/K
选项。
> cmd /K dir
使用参数运行程序 (Run Program with Parameter)
We generally need to provides parameters to the commands executed by cmd
. We can provide these parameters after the command like below. In this example we will provide the file name to the command.
我们通常需要为cmd
执行的命令提供参数。 我们可以在如下命令之后提供这些参数。 在此示例中,我们将为命令提供文件名。
> cmd dir "c:\Users"
关闭回音 (Turn Echo Off)
Commands those creates output to the shell will print output the the cmd
. We can turn these output off to make things more clear.
那些将输出创建到shell的命令将输出cmd
输出。 我们可以关闭这些输出以使情况更清楚。
> cmd /Q dir
翻译自: https://www.poftut.com/windows-cmd-exe-command-shell-tutorial-examples/