| 1. |
Solve : %%G help? |
|
Answer» So The PROGRAM is SUPPOSE to ping each computer on the network and then display the name and the average ping in this format: Need to use Delayed Expansion. Your inside a FOR LOOP.Still getting the same error. It's suppose to be Code: [Select]setlocal EnableDelayedExpansioncorrect?Quote from: Lemonilla on July 03, 2012, 07:13:40 AM Still getting the same error.You are getting an error now. You didn't say anything about getting an error in your previous posts. Quote from: Squashman on July 03, 2012, 07:19:17 AM You are getting an error now. You didn't say anything about getting an error in your previous posts.My bad, was referring to the BUG as an error. I found the problem though. I was trying to write to net%c%.1, when I changed that to net!1!.1 it worked, so I believe that %c% was not UPDATING with my set /a c+=1. Final code: Code: [Select]@echo off set c=0 if exist *.1 del /f *.1 title Network Pinger setlocal EnableDelayedExpansion net view | find "\\" >>network.1 for /f %%G IN (network.1) DO ( set /a c+=1 echo %%G >>net!c!.1 ) set m=%c% set c=0 :loop.rename set /a c+=1 set y=\\ set /p y=<net!c!.1 set y=%y:~2,100% ping %y% | find "Min" >>ping%c%.1 if %c% EQU %m% goto break.rename goto loop.rename :break.rename set c=0 :loop.view set /a c+=1 type net%c%.1 set /p a=<ping%c%.1 FOR /F "tokens=4 delims==" %%G IN ("%a%") DO ( echo %%G ) if %c% EQU %m% goto break.view goto loop.view :break.view del /f *.1 pause >nul Quick question, when pinging a computer name, will it be effected by internet usage? (i.e. If I have 120 pictures loading on the internet and ping myself, will the loading of the pictures slow down the packets?)Quote I believe that %c% was not updating with my set /a c+=1. For delayed-expansion to work you need two things 1. Setlocal enabledelayedexpansion 2. The variable name to be expanded is preceded and followed by exclamation marks NOT percent signs. |
|