0

I created a bat file that allows me to do more quickly. When I run a command (5), he remains open with ""Press any key to continue . . . ", while if I do the command (6), it closes automatically...

@ECHO OFF
CLS
ECHO 5.Show Router
ECHO 6.Run SASS
ECHO.

CHOICE /C 56 /M "Select:"

:: Note - list ERRORLEVELS in decreasing order
IF ERRORLEVEL 6 GOTO GulpSass
IF ERRORLEVEL 5 GOTO ShowRouter

:ShowRouter
@echo off
title Show Router
cd c:\xampp\htdocs\laravel
php artisan route:list
@pause
GOTO

:GulpSass
@echo off
title Codifico SASS
cd c:\xampp\htdocs\laravel
npm run dev
@pause
GOTO

:End

Because in gulpsass, if I did @pause, does it close the window while ShowRouter no?

aschipfl
  • 33,626
  • 12
  • 54
  • 99
LegoLiam
  • 97
  • 3
  • 11
  • 2
    `npm` is a batch file and when invoked the flow control is transfered to the called file and does not return to caller. Try with `call npm run dev` – MC ND Jul 31 '17 at 11:52
  • Thanks, it works! It's possible continue to write, Without having to close the window to open a new? – LegoLiam Jul 31 '17 at 11:56
  • `IF ERRORLEVEL 6 GOTO GulpSass` is wrong as the exit code of `CHOICE` on user presses key 6 is `2` because of being second option. So you need `IF ERRORLEVEL 2 GOTO GulpSass`. And the next line can be safely removed as `ShowRouter` is the only possibility remaining and is the next executed line. And because of using `npm` I suggest to read the answer on [change directory command cd ..not working in batch file after npm install](https://stackoverflow.com/questions/38676130/). – Mofi Jul 31 '17 at 13:22

0 Answers0