Jump to content

Recommended Posts

Posted

I'm also working on a script similiar to this. Once I'm done, I'll share executable. Though it won't ping all pc at once, but it very fast base on ping. My purposes might not serve the same as yours, but close to it. What mine does is it pings whatever computer name on the text file temp.txt. Temp.txt is what you'll need to put a pc name and it try to search the pc name in your network and return rather it's alive or dead onto a spreadsheet. It also include the ip address, hostname, and status. I just started so it might take awhile because i'm a beginner.

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Posted

If someone can turn this into autoit scripting then this should do the job. I grab it from somewhere else and modify a little. Don't remember the author...

@echo off

set ComputerList=C:\servers.txt

Echo Computername,IP Address,Mac Address>Final.csv
setlocal enabledelayedexpansion

for /f "usebackq tokens=*" %%A in ("%ComputerList%") do (
for /f "tokens=3" %%B in ('ping -n 1 -l 1 %%A -4') do (
If %%B==could set IPadd=PC is off or Not on Network.
)
for /f "tokens=3" %%A in ('ping -n 1 -l 1 %%A -4 ^|findstr Reply') do (
set IPadd=%%A
)
If /i "!IPAdd!" NEQ "Not on Network." (
for /f "Tokens=1" %%d in ('getmac /s %%A /nh') do set MacAdd=%%d)
echo %%A,!IPadd:~0,-1!,!MacAdd!>>final.csv
)

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
  • Moderators
Posted

I see that as no different than this (slower, in fact):

#include <File.au3>

$file = @DesktopDir & "\Servers.txt"

Local $aArray
    _FileReadToArray($file, $aArray)

    For $element In $aArray
        $var = Ping($element, 100)
            If $var Then FileWriteLine(@DesktopDir & "\Ping.txt", $element & " is on the network!")
    Next

The OP is looking for a way to ping them all at the same time, which he is not going to acheive with AutoIt (still not sure why he'd even want to).

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted (edited)

Since you can call ping from cmd, you should be able to pull this off (don't know about 4000) from one script if you treat each cmd instance asynchronously and just have a system to read the many stdout... right?

EDIT: It's ugly, but may work.  I am also curious as to the intent here though.  Any sort of intrusion detection system is going to start temp blacklisting this box if it's not completely useless.

Still don't know why you haven't attempted to do what I recommended.

Maybe there is a limit to how many can really run at once?

This works fine in my quick testing (pointing to the same machine multiple times just as a test)

#include <Constants.au3>
#include <Array.au3>
Global $aPing[1][3] = [['0','','']]
Global $aResults[1][2] = [['0','']]
AdlibRegister('_readstdout', 250)
_asyncping('127.0.0.1')
_asyncping('10.10.10.10')
_asyncping('10.10.10.11')
_asyncping('10.10.10.12')
_asyncping('10.10.10.13')
_asyncping('10.10.10.14')
_asyncping('10.10.10.15')
_asyncping('10.10.10.16')
_asyncping('10.10.10.17')
_asyncping('10.10.10.18')
_asyncping('10.10.10.19')
_asyncping('10.10.10.20')

While UBound($aPing) > 1
    Sleep(10)
WEnd

_ArrayDisplay($aResults)

func _asyncping($sIP)
    ReDim $aPing[UBound($aPing) + 1][3]
    $aPing[UBound($aPing) - 1][0] = Run(@ComSpec & " /c ping " & $sIP, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    $aPing[UBound($aPing) - 1][1] = $sIP
    $aPing[UBound($aPing) - 1][2] = ''
EndFunc

func _readstdout()
    For $a = 1 To UBound($aPing) - 1
        If $a > UBound($aPing) - 1 Then ExitLoop
        $aPing[$a][2] &= StdoutRead($aPing[$a][0])
        If @error Then
            ReDim $aResults[UBound($aResults) + 1][2]
            $aResults[UBound($aResults) - 1][0] = $aPing[$a][1]
            $aResults[UBound($aResults) - 1][1] = $aPing[$a][2]
            _ArrayDelete($aPing, $a)
        EndIf
    Next
EndFunc

EDIT: removed internal work IP's so I don't get scolded :P

Edited by danwilli
Posted (edited)

Head over My Friend spudw2k designed this. Like Water mention; it won't do all at once, but at least it will get your work done. Good luck!

Edited by asianqueen

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...