是否还有批处理文件中用户输入的预设数据? [英] Is there anyway to have preset data for user input in a batch file?

查看:146
本文介绍了是否还有批处理文件中用户输入的预设数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上我有一个批处理文件,需要很多用户输入。我想知道是否有可能有任何填充数据已经存在的问题时,如果用户需要更改的东西,他们可以去编辑那些数据。例如

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


然后用户输入他们的名字和姓氏。

And then the user enter their first and last name.

但是否可以从默认名称开始,用户可以返回并编辑,如果他们需要?

But is it possible to start with a default name that the user can go back and edit if they need?

这可能没有必要,但这是我使用的代码

This probably isn't necessary, But this is the code I use for the user input.

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

我理解对于作者,有没有什么意义,有预设数据,但有其他情况下,它将对我有用去做这个。是否有可能?

And I understand for the Author it wouldn't make much sense to have preset data, but there are other instances where it would be useful for me to do this. Is it possible?

推荐答案

以下方法会给用户输入数据前清除屏幕带来不便,正在努力解决这一点:

The method below have the inconvenience that the screen must be cleared before the user enter the data, but I am working trying to solve this point:

EDIT :我修复了第一个版本的细节

EDIT: I fixed the detail of the first version

@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));

有关详细信息,请参阅此帖

For further details, see this post.

这篇关于是否还有批处理文件中用户输入的预设数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆