创建一个 .bat 文件和 运行 多个调用命令
create a .bat file and run multiple command with call
我想运行批处理文件中的一些命令并使用 if 语句。
@echo off
call npm install
echo node js instaled
if not errorlevel 1 (
call composer install
if not errorlevel 1 (
echo commands run success.
) else (
echo please install composer and then run this batch again.
)
) else (
echo you have not nodejs in your system. please install nodejs.
)
当我 运行 这个批处理文件在 npm 安装完成后说
node js installed
if was unexpected at this time.
我如何检查命令是否成功,然后 运行 其他命令。
试一试:
@echo off
call npm install && (
echo node js installed
call composer install && (
echo Composer installed
) || echo composer install failed
) || echo Nodejs install failed
&&
是有条件的,如果第一个命令成功,那么运行下一个。 ||
将成为 else
运算符。
我想运行批处理文件中的一些命令并使用 if 语句。
@echo off
call npm install
echo node js instaled
if not errorlevel 1 (
call composer install
if not errorlevel 1 (
echo commands run success.
) else (
echo please install composer and then run this batch again.
)
) else (
echo you have not nodejs in your system. please install nodejs.
)
当我 运行 这个批处理文件在 npm 安装完成后说
node js installed
if was unexpected at this time.
我如何检查命令是否成功,然后 运行 其他命令。
试一试:
@echo off
call npm install && (
echo node js installed
call composer install && (
echo Composer installed
) || echo composer install failed
) || echo Nodejs install failed
&&
是有条件的,如果第一个命令成功,那么运行下一个。 ||
将成为 else
运算符。