我希望获得有关输入的帮助:
echo Downloading (SUPPOSED TO BE THE SAME AS WHAT IS THE LAST %RANDOM% OBJECT)manager.file
我想将()
中的文本设为与最后一个%random%
对象相同的句子的文本
我想做的是一个无限下载的批处理文件,但这只是回声和ping。这是我尝试过的:
@echo off
:loop
echo Downloading %random%.file
PING -n 0.5 127.0.0.1>nul
echo Downloading (SUPPOSED TO BE THE SAME AS WHAT IS THE LAST %RANDOM% OBJECT)manager.file
PING -n 1.5 127.0.0.1>nul
goto loop
答案 0 :(得分:2)
有两种方法可以做到这一点:
您要做的是在变量中分配文本。
第一种方法::仅使用1个子例程(loop
):
@echo off
:loop
set "rand=%random%"
set "text1=Downloading %rand%.file"
set "text2=Downloading (SUPPOSED TO BE THE SAME AS WHAT IS THE LAST %rand% OBJECT)manager.file"
echo %text1%
ping -n 0.5 127.0.0.1>nul
echo %text2%
ping -n 1.5 127.0.0.1>nul
goto loop
第二种方法:使用2个子例程(set_random
和loop
)进行操作:
@echo off
call:set_random
:loop
call:set_random
echo %text1%
ping -n 0.5 127.0.0.1>nul
echo %text2%
ping -n 1.5 127.0.0.1>nul
goto loop
:set_random
set "rand=%random%"
set "text1=Downloading %rand%.file"
set "text2=Downloading (SUPPOSED TO BE THE SAME AS WHAT IS THE LAST %rand% OBJECT)manager.file"
希望这会有所帮助!