![cmd命令和dos命令](https://i-blog.csdnimg.cn/blog_migrate/7f28926ab3ee9bdaeff1ff95a76ea823.png)
cmd命令和dos命令
MS-DOS is an operating system and shell used to run commands and provide a command-line interface in Windows operating systems. cmd.exe is used to interpret and provide a console for the MS-DOS command. cmd.exe provides different options where cmd /c
is a popular one. cmd /c
is used to run commands in MS-DOS and terminate after command or process completion.
MS-DOS是用于在Windows操作系统中运行命令并提供命令行界面的操作系统和外壳程序。 cmd.exe用于解释和提供MS-DOS命令的控制台。 cmd.exe提供了不同的选项,其中cmd /c
是流行的选项。 cmd /c
用于在MS-DOS中运行命令,并在命令或进程完成后终止。
运行命令并使用CMD / C终止 (Run Command and Terminate with CMD /C)
We can run commands in MS-DOS or in cmd.exe
by using cmd /c
. We will also add the command string we want to run. For example, if we want to run ping poftut.com we will issue the following command. The command will create a process that will run command and then terminate after the command execution is completed. Also using ” double quotes in order to surround command are very useful.
我们可以使用cmd /c
在MS-DOS或cmd.exe
运行命令。 我们还将添加要运行的命令字符串。 例如,如果我们想运行ping poftut.com,我们将发出以下命令。 该命令将创建一个将运行命令的进程,然后在命令执行完成后终止。 另外,使用“双引号将命令括起来也是非常有用的。
> cmd /c "ping poftut.com"
![Run Command and Terminate with CMD /C](https://i-blog.csdnimg.cn/blog_migrate/5f0f93d0cb8c375feca0423affe1205a.png)
运行命令并以CMD / C运行命令提示符终止(Run Command and Terminate with CMD /C On-Run Command Prompt)
We can run cmd /c
and related commands from the Run Command prompt. We can open Run Command Prompt from the Start menu or with the Windows Key+R key combination and write the cmd /c "ping poftut.com"
command like below. Keep in mind that after the execution of the command is completed the MS-DOS windows will be terminated or closed automatically.
我们可以从“运行命令”提示符下运行cmd /c
和相关命令。 我们可以从“开始”菜单或使用Windows Key + R组合键打开“运行命令提示符”,然后编写cmd /c "ping poftut.com"
命令,如下所示。 请记住,命令执行完成后,MS-DOS窗口将自动终止或关闭。
![Run Command and Terminate with CMD /C On Run Command Prompt](https://i-blog.csdnimg.cn/blog_migrate/77106dbf252e84c8df3546ed7568241c.png)
在搜索提示或搜索框上运行命令并以CMD / C终止(Run Command and Terminate with CMD /C On Search Prompt or Box)
Another alternative to run commands with the cmd /c
we can use Search Prompt or Box. We will click to the Start Menu and write down the complete command. This will also show the command with the MS-DOS icon like below. This will work like previous examples.
使用cmd /c
运行命令的另一种方法是我们可以使用搜索提示或Box。 我们将单击“开始”菜单并写下完整的命令。 这还将显示带有MS-DOS图标的命令,如下所示。 这将像前面的示例一样工作。
![Run Command and Terminate with CMD /C On Search Prompt or Box](https://i-blog.csdnimg.cn/blog_migrate/32b7a4dfd4d88d41ffdd507e350b21e1.png)
运行命令并以CMD / C运行命令提示符终止(Run Command and Terminate with CMD /C On-Run Command Prompt)
Alternatively, we can run cmd /c
command from a regular command line or MS-DOS. This will open a new MS-DOS shell and run given command. After the command execution is over the newly created MS-DOS shell will be terminated or closed automatically.
或者,我们可以从常规命令行或MS-DOS运行cmd /c
命令。 这将打开一个新的MS-DOS shell并运行给定命令。 在命令执行结束后,新创建的MS-DOS shell将被终止或自动关闭。
> cmd /c "ping poftut.com"
![Run Command and Terminate with CMD /C On Run Command Prompt](https://i-blog.csdnimg.cn/blog_migrate/5e08e41566ffa3ab605f1e39cc3646c7.png)
运行多个命令(Run Multiple Commands)
We can run multiple commands with the cmd /c
. We just need to provides them in double-quotes by separating them with space. In this example, we will run ping poftut.com
, ping google.com
, mkdir test
in the following example.
我们可以使用cmd /c
运行多个命令。 我们只需要通过用空格将它们分开来提供双引号即可。 在此示例中,我们将在以下示例中运行ping poftut.com
, ping google.com
, mkdir test
。
> cmd /c "ping poftut.com" "ping google.com" "mkdir test"
运行蝙蝠文件并终止 (Run Bat File and Terminate)
Bat or batch files are used to run multiple commands from a file. This will make recurring tasks easier. We can run a bat file by providing its path and name to the cmd /c
like below. In this example, we will run the batch file backup.bat
Bat或批处理文件用于从文件运行多个命令。 这将使重复任务变得更容易。 我们可以通过提供cmd /c
路径和名称来运行bat文件,如下所示。 在此示例中,我们将运行批处理文件backup.bat
> cmd /c C:\backup.bat
运行命令并使用CMD / K返回到CMD提示符 (Run Command and Return To CMD Prompt with CMD /K)
As stated previously cmd /c
will run given the command and terminate a new shell or process after the command is completed. If we do not want to terminate a new process we can use /K
option where a newly created process or window will remain without closing.
如前所述, cmd /c
将在给定命令的情况下运行,并在命令完成后终止新的Shell或进程。 如果我们不想终止新进程,则可以使用/K
选项,其中新创建的进程或窗口将保留而不关闭。
> cmd /k "ping poftut.com"
翻译自: https://www.poftut.com/what-does-cmd-c-means-in-windows-msdos-commandline-tutorial-with-examples/
cmd命令和dos命令