我需要在批处理文件中记录特定的信息片段,但我不知道如何
I need to log a certain snippet of information in a batch file, and I don't know how
好的,我目前正在创建一个人工智能程序(非常基础),
我需要能够记录用户输入的名称。我不明白发布的其他文章。
这是代码区域:
set /p input= Before we talk, I'd like to ask your name so I can properly address you. Please print your name.
set /p Name=
正如您在这里看到的,我们有一个输入区域,我需要该文件来保存输入的文本,并在您每次进入该程序时重新打开该文件并使用该名称。
在此先感谢您的帮助!
set /p Input=Enter name?
echo set Input=%input% > "c:\somefolder\somefile.bat"
使用
if not defined %input% call "c:\somefolder\somefile.bat"
参见 if /?
、echo /?
和 set /?
。
@echo off
setlocal EnableDelayedExpansion
call :GetName
if not defined Name (
echo Before we talk, I'd like to ask your name. Please print your name.
set /p Name=
echo set "Name=!Name!" >> "%~F0"
) else (
echo Hello %Name%, I am glad to see you again.
)
rem The rest of the code goes here...
goto :EOF
rem Be sure that the next is the last line in this file:
:GetName
好的,我目前正在创建一个人工智能程序(非常基础), 我需要能够记录用户输入的名称。我不明白发布的其他文章。 这是代码区域:
set /p input= Before we talk, I'd like to ask your name so I can properly address you. Please print your name.
set /p Name=
正如您在这里看到的,我们有一个输入区域,我需要该文件来保存输入的文本,并在您每次进入该程序时重新打开该文件并使用该名称。 在此先感谢您的帮助!
set /p Input=Enter name?
echo set Input=%input% > "c:\somefolder\somefile.bat"
使用
if not defined %input% call "c:\somefolder\somefile.bat"
参见 if /?
、echo /?
和 set /?
。
@echo off
setlocal EnableDelayedExpansion
call :GetName
if not defined Name (
echo Before we talk, I'd like to ask your name. Please print your name.
set /p Name=
echo set "Name=!Name!" >> "%~F0"
) else (
echo Hello %Name%, I am glad to see you again.
)
rem The rest of the code goes here...
goto :EOF
rem Be sure that the next is the last line in this file:
:GetName