尊敬的StackOverFlow会员,从另一个批处理文件更新批处理文件
请帮助我处理这个批处理文件。我想使用从“SET/P INPUT =%=%”给出的答案,并让它永久更新另一个批处理文件。
这是一个运行于用户
@echo off
cls
echo.
echo .................................................................
echo ..... Specify what the name of the Store is, this will send .....
echo ............... alerts to [email protected] ..............
echo .................................................................
echo.
pause
:option
cls
color 5E
echo.
echo "............ Press 1 to specify what the store name is......"
echo "............ Press 2 to exit the program ................."
echo.
SET /P M=Type from the menu above 1 or 2 then press ENTER:
IF %M%==1 GOTO SEND
IF %M%==2 GOTO EOF
:SEND
cls
color 0A
set INPUT=
set /P INPUT=Enter Store Name: %=%
if "%INPUT%"=="" goto input
echo "You said that the store name is: %INPUT%"
:: Have the user confirm his/her choice
SET /P ANSWER=Is the name correct (Y/N)?
echo You chose: %ANSWER%
if /i {%ANSWER%}=={y} (goto :yes)
if /i {%ANSWER%}=={yes} (goto :yes)
goto :no
:yes
echo You pressed YES!... The name is updating
goto name
:no
echo You pressed NO!... The program will exit
pause
cls
goto eof
:name
::set /A store=%INPUT%
echo %INPUT% >> notify_support.bat
::Terminate the program
:EOF
得到答案正如你可以看到我很努力指定我应该“回声%的输入%>> notify_support.bat”第一批文件。这是第二个批处理文件
@echo off
call senditquiet -s smtp.gmail.com -port 587 -u [email protected] -protocol ssl -p access -f [email protected] -t [email protected] -subject "Store ABC" -body "Hello there, There is an issue logged at the store.<br>Best regards."
当第一个批处理文件运行时,它会更新第二个采取了代码,但只是转储它在文件的结尾。
我需要INPUT ECHOed来替换第二个批处理文件中的“Store ABC”。
请协助,我很生疏的批处理文件。
嗨@GolezTrol,我应该然后使第二个批处理文件为空,并有第一个批处理文件解析它。就好像第一个文件正在为我写第二个文件,使用>解决方案? –
如果您选择实际解析批处理文件,则必须生成第二个文件,之后将重命名该文件,否则此时您正在覆盖正在阅读的文件。 (不确定,顺便说一下,也许文件在运行'for/F'时立即被读取)。无论如何,它很难实现,依赖于第二个文件的存在*和*依赖于'存储ABC标记,这意味着您不能重复该过程。 – GolezTrol
所以我建议不要解析它。你可以覆盖它。但为了做到这一点,第一批文件必须确切地知道进入第二个文件的内容。这样做的好处是实现起来更容易,甚至可以第一次生成第二个文件;它不一定存在。第一个文件需要包含第二个批处理文件的'模板'可能是一个缺点,但是由您决定是否可以接受。 – GolezTrol