DOS batch files: how to write at the invitation and stay on the same line for entering text

I like to know if there is a way to read the user input inside the batch file because I have a file named: "fif.bat" that returns two parameters (just call them paramA and paramB ), so I run the file like this:

fif paramA paramB 

I need to change paramA every month, but I call this file many times, so I like to open the console and print this:

 fif paramA 

Therefore, I only need to write paramB and change paramA whenever I want.

PD: paramA is very large, so it is very useful if I can have it there instead of writing it every time. And I don't want another batch file to call fif whit paramA.

+4
source share
2 answers

I think this might be what you are looking for:

 @ECHO OFF SET /p paramA=Parameter A: ECHO you typed %paramA% PAUSE 

Line 1 stops the commands in the batch file from echoing to the console. Line 2 asks the user for “Parameter A:” and waits for the user to enter a value and press “Enter”. The value goes into paramA variable. Line 3 echoes the value of the paramA variable to the console. Line 4 expects the user to hit any key.

Please note that the SET / p command does not work for each version of the windows, I believe that it was introduced in 2000, but I could be mistaken in the version.

+7
source

You can request user input in a batch file using SET /P , for example:

 SET /P paramB="Prompt String: " 
0
source

Source: https://habr.com/ru/post/1277767/


All Articles