Batch file 创建一个.bat文件并通过调用运行多个命令
我想在批处理文件中运行一些命令并使用if语句Batch file 创建一个.bat文件并通过调用运行多个命令,batch-file,command,npm-install,Batch File,Command,Npm Install,我想在批处理文件中运行一些命令并使用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 b
@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
操作符