V
V
Vasya Nikolaev2017-06-10 17:13:25
cmd/bat
Vasya Nikolaev, 2017-06-10 17:13:25

How can I set a command to be executed in a BAT file if the user enters y?

You want the yarn init command to create index.html and ask you if you want to install bourbon. Interested in the question of how to offer the user the installation of bourbon (or another package).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Tallmange, 2017-06-10
@p00h

@echo off
set /p id="Enter ID: "

M
Moskus, 2017-06-11
@Moskus

The command
is good for entering text (and requires pressing enter at the end).
Here's a simple confirmation:

choice /t 5 /d N /m "Would you like to install ... package?"
if errorlevel 2 goto sub noinstall
if errorlevel 1 goto sub install

Where /t sets the input timeout, /d is the default value (which will be selected after 5 seconds if nothing is entered, /m sets the message. Well, then check the value of the result (Y-1, N-2) and go to the label.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question