Execute command together with file in a .bat file

1

I am trying to create a .bat file to be able to boot the gulp system that I have.

What I do so far is open a DOS console, go to the path 'D: \ my_project \ gulp \ bin' then run the command 'gulp.js serve' and it starts with it.

I want to automate it in a .bat and for that I made a file with these instructions:

@echo off
D:\mi_proyecto\gulp\bin\gulp.js serve
exit

But it does not work for me. I also tried putting quotation marks on the orders:

@echo off
D:\mi_proyecto\gulp\bin\"gulp.js serve"
exit

But neither. Can someone please give me a hand with this? Thanks.

    
asked by Ucha 19.02.2018 в 12:44
source

5 answers

1

I found the form. The content of the .bat file must be this:

@echo off
d:
cd D:\mi_proyecto\gulp\bin\
node .\gulp.js serve

What you do first is go to disk D with the line d: (since the file and the command that I want to execute are on my disk D). Then, the third line, causes the route to be positioned in the folder where the file that I want to execute is located. Finally, in the fourth line, node is the command that allows me to execute Javascript code (.js) and then the command serve is the one I use to start the server.

    
answered by 19.02.2018 / 17:03
source
0

I recommend that you do the following:

@echo off
cd D:\mi_proyecto\gulp\bin\
gulp.js serve
exit

With the cd you are placing yourself in that directory.

Another option if you want everything in one line would be something like this:

@echo off
cd D:\mi_proyecto\gulp\bin\ && gulp.js serve
exit

With the && allows you to make several orders in the same execution

Personally, I recommend the first option, since the second one has caused problems for me, although I'm not sure why.

    
answered by 19.02.2018 в 12:49
0

separates the instructions to change the unit with the directory change

@echo off
d:
cd \mi_proyecto\gulp\bin
gulp.js serve
exit
    
answered by 19.02.2018 в 13:32
0
@echo OFF
MODE con: cols=100 lines=30
@echo OFF
title servidor
COLOR 02
cd D:\mi_proyecto\gulp\bin\
call npm server.js

You can also replace these commands

call npm start
start http://localhost:3000/ && call npm start

The other option is that you go to variable environment and configure your project to be executed from cmd with a single letter or number that you put to your file.bat

    
answered by 17.11.2018 в 06:12
-1
@echo OFF
MODE con: cols=100 lines=30
@echo OFF
title Facebook
COLOR 02
@echo OFF
:menu
echo.
title Facebook
echo.                               __               _                 _    
echo.                              / _^|             ^| ^|               ^| ^|   
echo.                             ^| ^|_ __ _  ___ ___^| ^|__   ___   ___ ^| ^| __
echo.                             ^|  _/ _' ^|/ __/ _ \ '_ \ / _ \ / _ \^| ^|/ /
echo.                             ^| ^|^| (_^| ^| (_^|  __/ ^|_) ^| (_) ^| (_) ^|   ^< 
echo.                             ^|_^| ^\__,_^|^\___\___^|_.__/ \___/ \___/^|_^|^\_\
echo.                                Autor :Luishiño Pericena Choque       
echo.                                https://lpericena.blogspot.com/ 
echo.                                     
echo. Abrir Facebook en el navegador predeterminado.
echo.         [S] Si  
echo.         [N] No 
echo.         [C] Cancelar
echo.
set /p app= Seleccione una tarea [+]
if %app%==S goto :Si
if %app%==s goto :Si
if %app%==N goto :No
if %app%==n goto :No
if %app%==c goto :Cancelar
if %app%==C goto :Cancelar
:Si
start http://localhost:3000/ && call npm start
goto menu
:No
call npm start
goto menu
:Cancelar
cd ..
call facebook.bat
exit

You must have installed node js and put in the variable path environment and the declaration of extension .js

    
answered by 17.11.2018 в 06:16