---
title: "How can I run two commands in one line in Windows CMD?"  
description: "How can I run two commands in one line in Windows CMD?"  
author: "Utpal Vishwas"  
published: 2023-07-14  
updated: 2023-07-15  
canonical: https://www.mindstick.com/forum/159096/how-can-i-run-two-commands-in-one-line-in-windows-cmd  
category: "windows controls"  
tags: ["windows", "command line"]  
reading_time: 2 minutes  

---

# How can I run two commands in one line in Windows CMD?

How can I run two [commands](https://www.mindstick.com/interview/817/what-is-the-use-of-dbcc-commands) in [one line](https://www.mindstick.com/forum/158083/read-a-file-one-line-at-a-time-in-node-js) in [Windows](https://www.mindstick.com/articles/311752/how-to-install-and-use-the-google-wifi-software-on-a-windows-or-mac-computer) [CMD](https://www.mindstick.com/forum/145519/how-to-set-auto-shutdown-windows-10-by-cmd)?

## Replies

### Reply by Aryan Kumar

Sure, there are two ways to run two commands in one line in Windows CMD:

- **Using the ampersand (&)**

The ampersand (&) is a special character that can be used to run two commands in one line. When the ampersand is used, CMD will run the first command, and then the second command.

For example, to run the `dir` command and the `echo` command in one line, you would use the following command:

```plaintext
dir & echo "This is the second command."
```

This will first run the `dir` command, which will list the contents of the current directory. Then, the `echo` command will be run, which will display the text "This is the second command."

- **Using the semicolon (;)**

The semicolon (;) is another special character that can be used to run two commands in one line. When the semicolon is used, CMD will run the first command, and then the second command, but only if the first command is successful.

For example, to run the `dir` command and the `echo` command in one line, but only if the `dir` command is successful, you would use the following command:

```plaintext
dir ; echo "This is the second command."
```

This will first run the `dir` command. If the `dir` command is successful, the `echo` command will be run. However, if the `dir` command is not successful, the `echo` command will not be run.


---

Original Source: https://www.mindstick.com/forum/159096/how-can-i-run-two-commands-in-one-line-in-windows-cmd

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
