Is there anyway predefined data for user input in a batch file?

So basically I have a batch file that requires a lot of user input. I was wondering if it is already possible to have any filler data when this question is asked, and if the user needs to change something, they can edit this data. for instance

enter image description here And then the user enters his first and last name. enter image description here

But is it possible to start with the default name, which the user can go back and edit if he needs?

This is probably not necessary, but it is the code that I use for user input.

Set /p "Author=Please enter your name: "

And I understand that it would not make sense for the author to have predefined data, but there are other examples when it would be useful for me to do this. Is it possible?

+4
6

, , , :

EDIT:

@if (@CodeSection == @Batch) @then

@echo off
rem Enter the prefill value
CScript //nologo //E:JScript "%~F0" "First Last"
rem Read the variable
echo -----------------------------------------------------------
set /P "Author=Please enter your name: "
echo Author=%Author%
goto :EOF

@end

WScript.CreateObject("WScript.Shell").SendKeys(WScript.Arguments(0));

. .

+3

, (, set /p , )

set "author=First Last"
set /p "author=Enter name or press [ENTER] for default [%author%]: "
echo %author%
+6
askingFile.cmd < response.txt

,

0

var, , :

set Author=First Last
if not defined Author set /p "Author=Please enter your name: "

, , , :

set /p "Author=Please enter your name: "
if not defined Author set Author=First Last
0

- editv32.exe edit64.exe(http://www.westmesatech.com/editv.html), :

set NAME=Gill Bates
editv32 -p "Enter your name: " NAME

editv32.exe/editv64.exe - , .

0

Another alternative is ReadLine.exe:

@echo off
set NAME=First Last
for /f "delims=" %%n in ('ReadLine -p "Enter name: " -- %NAME%') do set NAME=%%n
echo You entered: %NAME%

You can get it from http://www.westmesatech.com/misctools.html . Source code included.

0
source

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


All Articles