我正在尝试将批处理文件中的用户输入变量保存到文本文件中。这样某些 javascript 就可以读取该文件来使用这些变量。
这是我目前所拥有的:
:varecho
echo %GAMEPIN% > variables.txt
echo %NICKNAME% >> variables.txt
goto launch
这只是将“ECHO 已关闭”写入variables.txt
:
我如何将变量的内容放入文件中?
答案1
答案2
@echo off
set /p "GAMEPIN= Enter your Game PIN: "
set /p "NICKNAME= Enter your NICKNAME: "
call :varecho "%GAMEPIN%" "%NICKNAME%"
goto launch
:varecho
>variables.txt (echo\%~1&echo\%~2) & exit /b
:launch
....
- 或者...
@echo off & cd /d "%~dp0"
set /p "GAMEPIN= Enter your Game PIN: "
set /p "NICKNAME= Enter your NICKNAME: "
> .\variables.txt (
call :varecho %GAMEPIN% %NICKNAME%
) & goto :launch
:varecho
echo\%~1
echo\%~2
exit /b
:launch
....