我想在Windows CMD控制台中运行两个命令。
在Linux中我会这样做
touch thisfile ; ls -lstrh
在Windows上是怎么做的呢?
我想在Windows CMD控制台中运行两个命令。
在Linux中我会这样做
touch thisfile ; ls -lstrh
在Windows上是怎么做的呢?
当前回答
在windows 10中,你也可以使用scriprunner:
ScriptRunner.exe -appvscript demoA.cmd arg1 arg2 -appvscriptrunnerparameters -wait -timeout=30 -rollbackonerror -appvscript demoB.ps1 arg3 arg4 -appvscriptrunnerparameters -wait -timeout=30 -rollbackonerror
它允许你在一行上启动几个命令,你可以连续运行它们,也可以不等待彼此,你可以设置超时和错误回滚。
其他回答
为了同时执行两个命令,必须在两个命令之间加上&(&)符号。像这样:
color 0a & start chrome.exe
干杯!
cmd /c ipconfig /all & Output.txt
该命令执行命令并在一个命令中打开Output.txt文件
&是Bash中等价的;&&是Bash中的&&(只在前一个没有导致错误时才运行命令)。
如果你想创建一个cmd快捷方式(例如在你的桌面上),添加/k参数(/k表示保持,/c将关闭窗口):
cmd /k echo hello && cd c:\ && cd Windows
再举一个例子:例如,当我们使用gulp构建系统时,而不是
Gulp -默认>构建
Gulp构建-构建构建文件夹
Gulp watch -开始文件监视
Gulp dist- build dist-folder
我们可以用一行代码来实现:
cd c:\xampp\htdocs\project & gulp & gulp watch