What Does CMD /C Means In Windows MS-DOS Command-line Tutorial with Examples?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/what-does-cmd-c-means-in-windows-msdos-commandline-tutorial-with-examples/
PINTEREST
PINTEREST
INSTAGRAM

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.

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 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 which will run command and then terminate after the command execution is completed. Also using " double quotes in order to surround command is very useful.

Run Command and Terminate with CMD /C
Run Command and Terminate with 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.

Run Command and Terminate with CMD /C On Run Command Prompt
Run Command and Terminate with CMD /C On Run Command Prompt

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.

LEARN MORE  How To Install and Use dos2unix Command In Linux?
Run Command and Terminate with CMD /C On Search Prompt or Box
Run Command and Terminate with CMD /C On Search Prompt or Box

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.

Run Command and Terminate with CMD /C On Run Command Prompt
Run Command and Terminate with CMD /C On Run Command Prompt

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 exapmle, we will run ping poftut.com, ping google.commkdir test in the following example.

Run Bat File and Terminate

Bat or batch files are used to run multiple commands from a file. This will make recurring task 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

Run Command and Return To CMD Prompt with CMD /K

As stated previously cmd /c will run given the command and terminate 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.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/what-does-cmd-c-means-in-windows-msdos-commandline-tutorial-with-examples/
PINTEREST
PINTEREST
INSTAGRAM