我需要有多个远程管理员在现场测试他们的下载速度。 Speedtest.net等都不是我们广域网中性能的真实指标。我不希望使用iperf,因为我需要尽量减少远程管理员的技术知识和工作量。我不希望他们也不得不安装任何东西。因此我需要一个简单的批处理文件来下载一个测试文件5次。这是我到目前为止:批处理脚本for循环不工作
@echo off
rem localize variables to this script
setlocal
rem delete the test file if it already exists
if exist %HomePath%\Downloads\100meg.test del %HomePath%\Downloads\100meg.test
rem perform the test 5 times
for /l %%i IN (1,1,5) DO (
rem mark the start time
set STARTTIME=%TIME%
echo Download started at:%STARTTIME%
rem start download
C:\windows\explorer.exe http://mirror.internode.on.net/pub/test/100meg.test
rem check for file download completion
:while
if exist %HomePath%\Downloads\100meg.test goto wend
goto while
:wend
rem mark the end time
set ENDTIME=%TIME%
echo Download completed at:%ENDTIME%
rem convert STARTTIME and ENDTIME to centiseconds
set /A STARTTIME=(1%STARTTIME:~0,2%-100)*360000 + (1%STARTTIME:~3,2%-100)*6000 + (1%STARTTIME:~6,2%-100)*100 + (1%STARTTIME:~9,2%-100)
set /A ENDTIME=(1%ENDTIME:~0,2%-100)*360000 + (1%ENDTIME:~3,2%-100)*6000 + (1%ENDTIME:~6,2%-100)*100 + (1%ENDTIME:~9,2%-100)
rem calculate the time taken in seconds
set /A DURATION=(%ENDTIME%-%STARTTIME%)/100
echo Download took:%DURATION% seconds
rem delete the test file ready for next iteration
del %HomePath%\Downloads\100meg.test
)
问题是,因为添加for并将括号括起来,它停止工作。任何人都可以阐明为什么这是失败的?
谢谢!
注释掉“@echo off”,看看有什么失败。 – jdigital
好的,首先脚本似乎设置了变量,但立即忘记它: C:\ Users \ j \ Desktop> for/L%i IN(1 1 5)DO( set STARTTIME = 11:59:26.39 回声下载的开始: 暂停 其次,它只有通过for循环 – James
单次迭代去(这个网站有未格式化的,以前的评论,我只想说,“下载开始时间:”读取“下载开始时间: 11:59:26.39“for循环未使用时 –
James