MS-DOS |获取用户输入而不提示

时间:2017-04-03 15:59:11

标签: dos

我必须创建一个批处理文件,该文件将用户输入保存并显示在log.txt文件中。但是,用户/我的老师将输入如下文字:

'批处理文件名在这里'.bat“frank”f123

我必须使用他们输入的名称和用户名并将其显示如下:

坦率

f123

我可以得到这个名字但是上面我得到'Echo is off'。目前我的代码:

@echo off

name =

用户名=

如果不存在“c:\ User_records”md c:\ User_records

@echo%name%>> c:\ User_records \ Users.txt

@echo%username%>> c:\ User_records \ Users.txt

@echo%date %% time%>> c:\ User_records \ Users.txt

1 个答案:

答案 0 :(得分:0)

试试这个:

@echo off
set name=%~1
set username=%~2
if not exist "c:\User_records" md c:\User_records
@echo %name% >>c:\User_records\Users.txt
@echo %username% >>c:\User_records\Users.txt
@echo %date% %time% >>c:\User_records\Users.txt
echo %name%
echo %username%