Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8826801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:13:43+00:00 2026-06-14T07:13:43+00:00

I need to have multiple remote admins test their download speeds at site. Speedtest.net

  • 0

I need to have multiple remote admins test their download speeds at site. Speedtest.net and alike aren’t a true indicator of performance in our WAN. I don’t wish to use iperf as I need to minimise the technical knowledge and effort of the remote admins. I don’t want them to have to install anything either. Therefore I need a simple batch file to download a test file 5 times. This is what I have so far:

@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
)

The problem is that since adding the for and enclosing the block in its brackets, it’s stopped working. Can anyone shed any light on why this is failing?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:13:44+00:00Added an answer on June 14, 2026 at 7:13 am

    Using GOTO within a FOR loop always breaks the loop – the remaining iterations will not occur once you use GOTO.

    This is because of the way CMD.EXE works. The entire block of commands within the parentheses is parsed and loaded into memory all at once. Each iteration executes the already parsed commands that are stored in memory. These parsed commands do not include any label. GOTO must scan the file, which requires breaking the loop.

    The “disappearing” value of STARTTIME also has to do with the fact that the entire block is parsed at once. %STARTTIME% is expanded at parse time, but the command is parsed before any of the block is executed. So you are getting the value that existed before the FOR command is executed, which is probably undefined. There is a feature called delayed expansion that can be used to get the value of a variable at execution time instead of parse time. Type HELP SET from the command prompt and read the section about delayed expansion that starts about half way through the documentation.

    But there is a simple way to get your code to work – just move the contents of the DO block to a subroutine and then CALL the routine within your loop. (I’m assuming your logic within the DO clause is otherwise correct). The CALL does not break the loop 🙂

    You must remember to put an EXIT /B before your routine label so that your main code does not fall through to the subroutine.

    @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 call :downloadTest
    exit /b
    
    :downloadTest
    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
    exit /b
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple Nunit test DLL's like a_test.dll, b_test.dll, c_test.dll. Whenever I need to
I need to create a WP site which will have multiple subjects. Each subject
Hello I need to have multiple language support of my django admin application.I can
Do I need to have separate/multiple workers to run multiple websites (each with a
I have multiple threads who all need to write to the same Dictionary. I
I have multiple tables that need to be merged into one. SELECT name, SUM(money)
I have multiple ajax requests with javascript code as response, and I need to
I have multiple git repositories to have some interdependencies between them. I need to
I have multiple applications each having a GUI from a different technology. I need
The problem is this: I have multiple competing threads (100+) that need to access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.