批量set命令后,回声文本 [英] Echo text after the set command in batch
本文介绍了批量set命令后,回声文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法回应一组命令后的文本?我都试过了,但似乎没有任何工作。这里是我的code:
Is there way to echo text after a set command? I have tried, but nothing seems to work. Here is my code:
@echo off
Echo Enter a website:
Set /p op="Https:\\" ".com"
:: The ".com" would be displayed behind the users input.
if %op%==%op% goto Show
:Show
cls
Echo Website: Http:\\%op%.com
pause
exit
我该如何获得要显示的.COM之后输入?我想preferably喜欢有.COM在一个地方,冻结不管用户输入有多大。
How would I get the .com to be displayed after the input? I would preferably like to have the ".com" frozen in one spot, no matter how big the users input is.
推荐答案
我从的这个答案并略作修改它,以满足这一要求。
I took the solution from this answer and slightly modified it in order to fulfill this request.
@echo off
setlocal EnableDelayedExpansion
for /F %%a in ('echo prompt $H ^| cmd') do set "BS=%%a"
for /F %%a in ('copy /Z "%~F0" NUL') do set "CR=%%a"
set "op="
set /P "=Https:\\.com!BS!!BS!!BS!!BS!" < NUL
:nextKey
set "key="
for /F "delims=" %%K in ('xcopy /W "%~F0" "%~F0" 2^>NUL') do if not defined key set "key=%%K" & set "key=!key:~-1!"
if "!key!" equ "!CR!" goto endInput
if "!key!" neq "!BS!" (
set "op=%op%%key%"
set /P "=.!BS!%key%.com!BS!!BS!!BS!!BS!" < NUL
) else if defined op (
set "op=%op:~0,-1%"
set /P "=.!BS!!BS!.com !BS!!BS!!BS!!BS!!BS!" < NUL
)
goto nextKey
:endInput
echo/
echo/
echo Website: Http:\\%op%.com
修改:添加了新的方法(在评论的要求)的
@echo off
setlocal EnableDelayedExpansion
set /A spaces=10, backSpaces=spaces+4
set "spcs="
for /L %%i in (1,1,%spaces%) do set "spcs=!spcs! "
set "back="
for /F %%a in ('echo prompt $H ^| cmd') do set "BS=%%a"
for /L %%i in (1,1,%backSpaces%) do set "back=!back!!BS!"
set /P "op=Https:\\%spcs%.com!back!"
echo/
echo Website: Http:\\%op%.com
这篇关于批量set命令后,回声文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文