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

  • SEARCH
  • Home
  • 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 8874543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:44:52+00:00 2026-06-14T18:44:52+00:00

This is something simple I’m missing I bet and I have a feeling it’s

  • 0

This is something simple I’m missing I bet and I have a feeling it’s not working the way I need because of the nested loop. This is a simple script I’ve pulled off somewhere and have modified a bit to allow for more testing. Essentially it just pings a host on a delay over and over for all time until you close it, but logs the failed responses. Everything works, but for the life of me I can’t figure out how to get it to update the name being used in the for loop.

@echo off
setlocal enabledelayedexpansion

:: ** Enter name to identify host in log **
set name1=Test 1
set name2=Test 2
set name3=Test 3

:: ** Enter IP or HOSTNAME to test against **
set hostIP1=1.1.1.1
set hostIP2=2.2.2.2
set hostIP3=3.3.3.3

:: ** Enter Delay in milliseconds between each test **
set delayMS=2000


title -DO NOT CLOSE- Ping Test
echo DO NOT CLOSE
echo Ping Test


:loop
set namecount=1
for %%x in (%hostIP1% %hostIP2% %hostIP3%) do (
set pingline=1
set pingname=name!namecount!
for /f "delims=" %%A in ('ping -n 1 -w 2000 -l 255 %%x') do (
    if !pingline! equ 2 (
        set logline=!date! !time! "%%A" - %%x !%pingname%!
        echo !logline! | find "TTL=">nul || echo !logline! >> pinglog.txt
        )
    set /a pingline+=1
    )
set /a namecount+=1
)
sleep -m %delayMS%
goto loop

Usually I’d use another language but I need something that works on windows servers of all kinds.. This seems like the surest way. 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-14T18:44:53+00:00Added an answer on June 14, 2026 at 6:44 pm

    This is incorrect:

    !%pingname%!
    

    Try this:

    !Pingname!
    

    I can’t try your code but i’ve made other minor corrections:

    (UPDATED)

     @echo off
    setlocal enabledelayedexpansion
    
    :: ** Enter name to identify host in log **
    set "name1=Test 1"
    set "name2=Test 2"
    set "name3=Test 3"
    
    :: ** Enter IP or HOSTNAME to test against **
    set "hostIP1=1.1.1.1"
    set "hostIP2=2.2.2.2"
    set "hostIP3=3.3.3.3"
    
    :: ** Enter Delay in milliseconds between each test **
    set /A "delayMS=2000"
    
    
    title -DO NOT CLOSE- Ping Test
    Echo DO NOT CLOSE
    Echo Ping Test
    
    :loop
    set /A "namecount=1"
    for %%x in (%hostIP1% %hostIP2% %hostIP3%) do (
        set /A "pingline=1"
        call set "pingname=%%name!namecount!%%"
        for /f "delims=" %%A in ('ping -n 1 -w 2000 -l 255 %%x') do (
            if !pingline! equ 2 (
                set "logline=%date% !time! %%A - %%x !pingname!"
                (echo !logline! | find "TTL=">nul) || (echo !logline! >> "pinglog.txt")
            )
            set /a "pingline+=1"
        )
        set /a "namecount+=1"
    )
    sleep -m %delayMS%
    goto :loop
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the feeling this is something simple that I am missing, but I
Hopefully this is something simple I am missing, I have an OL encompassing a
I know this is going to be something simple that I'm just missing somehow,
Perhaps I'm missing something simple, as I believe that this is a common scenario...
hope this is something simple and I am just missing it, but consider this
Hopefully this is something simple I'm missing but I'm trying to figure out why
This is something that I cannot believe I have not been able to figure
OK, Im really stumped and hoping this is something simple. I have a form
I am sure this is probably something simple that i am not doing. Running
This is something simple I came up with for this question . I'm not

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.