Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
how can i sue a text fiel as the source/set
Example
FOR %%a in (MyFile.txt) Do Ping %%a
Where MyFile.txt is a list of computer names in the following format:
computer1
computer2
computer3
computer4
...This way all I have to change is MyFile.txt and let the for command do its job.
Thanks.

Probably isn't the answer you were looking for, however have you looked into Windows "PowerShell" at all? It is free to use and a very valuable and powerful tool.
A person much smarter than I came up with the following powershell script. Maybe you can modify it to use it in your VB script, I'm not much for programming but I am generally resourceful enough to piggyback of someone elses work to get the same result...
Read through the directions and you will note that you only have to enter in the values for the variables that will define the network you would like to scan and the location where you would like to ouput the .txt file:
##
##Powershell script to perform a ping sweep and output responding ips to text file#
# Variable Explanation
# w is the first octet of desired ip scan example 192.168.1.1 192 is first octet 168 is second..
# x is second octet
# y is third octet
# z is fourth octet
# upperlimit is the upper limit for the scan
# address holds the entire ip address as a string
# Lastexitcode is a native powershell variable that holds the exit code of last native command executed
# Lastexitcode = 0 is success in this case a reply recieved
# this script uses the native ping command from M$ -n is how many pings to send -w is timeout in ms
#
$w = W
$x = x
$y = y
$z = z
$upperlimit = 201
$location = "c:\PingMe.txt"
while ($y -lt $upperlimit)
{ $address = "$w.$x.$y.$z"
if ($z -eq 255)
{
++$y
$z = 0
}
$z++
$address
ping -n 1 -w 50 $address > $null
if ($Lastexitcode -eq 0)
{$address >> $location}
}*I would like to give credit to the original author however their name has been lost through time. I'm sure this script is still readily available on the net if you want to find the original.

FOR /f %%a in (MyFile.txt) Do Ping %%a
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |