bat file code example

Example 1: bat stop if call command fails

The ERRORLEVEL environment variable holds the latest return value:
IF %ERRORLEVEL% NEQ 0 (
  echo "Previous command execution failed."
  exit %ERRORLEVEL%
)

Example 2: bat file

//Save it as start_dev.bat

@ECHO off
cd "C:\xampp"
start xampp-control.exe

cd "C:\Users\..."
start cmd /k "code . && ng s -o"
 
cd "C:\Users\..."
start cmd /k "code-insiders . && php artisan serve"

Example 3: what is a windows batch file

@ECHO OFF
ECHO Congratulations! Your first batch file executed successfully.
PAUSE