如何在Windows 10中使用cmd在一行中运行多个命令 [英] How to run multiple commands in one line using cmd in windows 10

查看:564
本文介绍了如何在Windows 10中使用cmd在一行中运行多个命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所述,我需要在Windows 10中使用cmd在一行中运行两个命令。

as the title said I need to run exactly two commands in one line using cmd in windows 10. How is it possible?

推荐答案

要运行两个命令,请使用& 。这两个命令都将执行:

to run two commands use &. Both commands will be executed:

dir file.txt & echo done

使用&& 仅在第一个命令成功的情况下才执行第二个命令:

Use && to execute the second command only if the first command was successful:

dir existentfile.txt && echo done

使用 || 运行仅当第一个命令失败时,第二个命令:

Use || to run the second command only if the first command failed:

dir nonexistentfile.txt || echo not found

您可以组合:

dir questionablefile.txt && (echo file exists) || (echo file doesn't exist)

这篇关于如何在Windows 10中使用cmd在一行中运行多个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆