hallo leute
da ich als admin ab und zu mal mein netzwerk nach ip's suchen muss, hab ich mir dieses skript geschrieben (danke an "Cyberdyne" für die hilfe)
dafür hab ich mir eine DLL in VB geschrieben, die die hostnamen der computer herausliest.
Skript:
Spoiler anzeigen
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=ico\ping.ico
#AutoIt3Wrapper_outfile=pingMyLan.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <iNet.au3>
#include <GuiIPAddress.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#Include <GuiListView.au3>
$dll = DllOpen("getHostname.dll")
If FileFindFirstFile("getHostname.dll") = -1 Then
MsgBox(16, "Fehler", "getHostname.dll wurde nicht gefunden!")
Exit
EndIf
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.0
Author: Gianni
Script Function:
Pingt IP's im LAN
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#Region ### START Koda GUI section ### Form=d:\programmierung\autoit\pingmylan\form\form.kxf
Global $ipSearchStarted = 0
Global $pingIP = "0.0.0.0"
Global $pingBis = 0
Opt("GUIOnEventMode", 1)
$form = GUICreate("pingMyLAN", 267, 273, 192, 124)
$inpIP = _GUICtrlIpAddress_Create($form, 96, 16, 100, 21)
_GUICtrlIpAddress_Set($inpIP, "192.168.0.1")
$labelIP = GUICtrlCreateLabel("IP-Adresse:", 16, 16, 75, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$labelBis = GUICtrlCreateLabel("-", 202, 8, 12, 33)
GUICtrlSetFont(-1, 18, 800, 0, "Arial")
$inpBis = GUICtrlCreateInput("255", 216, 16, 33, 21)
$statusBar = _GUICtrlStatusBar_Create($form)
_GUICtrlStatusBar_SetText ($statusBar, "Stop")
$ListView1 = GUICtrlCreateListView("IP | Hostname", 8, 88, 250, 150)
_GUICtrlListView_SetColumnWidth ($ListView1, 0, 100)
_GUICtrlListView_SetColumnWidth ($ListView1, 1, 135)
$btnStart = GUICtrlCreateButton("Start", 120, 48, 59, 25, $WS_GROUP)
$btnStop = GUICtrlCreateButton("Stop", 192, 48, 59, 25, $WS_GROUP)
$btnLoeschen = GUICtrlCreateButton("Liste löschen", 8, 70, 75, 17, $WS_GROUP)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlSetOnEvent($btnStart, "StartButton")
GUICtrlSetOnEvent($btnStop, "StopButton")
GUICtrlSetOnEvent($btnLoeschen, "_deleteList")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(1000)
If $ipSearchStarted Then
_pingIP($pingIP, $pingBis)
$ipSearchStarted = 0
_GUICtrlStatusBar_SetText ($statusBar, "Stop")
EndIf
WEnd
DllClose($dll)
Func StartButton()
If $ipSearchStarted Then return 0
$IPSearchStarted = 1
$pingIP = _GUICtrlIpAddress_Get($inpIP)
$pingBis = GUICtrlRead($inpBis)
EndFunc
Func StopButton()
If NOT $ipSearchStarted Then return 0
$IPSearchStarted = 0
EndFunc
Func CLOSEClicked()
If $ipSearchStarted Then
$a = MsgBox(1, "Ping Suche noch aktiv!", "Soll die Ping Suche abgebrochen werden?")
If NOT ($a = 1) Then Return
EndIf
Exit
EndFunc
Func _deleteList()
_GUICtrlListView_DeleteAllItems($ListView1)
EndFunc
Func _pingIP($ip, $ipBis)
$splitIP = StringSplit($ip, ".")
For $i = $splitIP[4] To $ipBis
If Not $ipSearchStarted Then ExitLoop
$ip = String($splitIP[1] & "." & $splitIP[2] & "." & $splitIP[3] & "." & $i)
_GUICtrlStatusBar_SetText ($statusBar, "Ping: " & $ip)
$ping = Ping($ip, 250)
If $ping > 0 Then
$hostname = DllCall($dll, "str", "getHostname", "str", $ip)
If Not @error Then $host = $hostname[0]
If $host <> "192" Then
$item1 = GUICtrlCreateListViewItem($ip & "|" & $host, $ListView1)
Else
$item1 = GUICtrlCreateListViewItem($ip & "|" & "NoName", $ListView1)
EndIf
EndIf
Next
EndFunc
getHostname.dll
Spoiler anzeigen
Public Class HostNameDLL
Public Shared Function getHostname(ByVal ipAdress As String) As String
Dim myHost As String
Dim host As Array
myHost = System.Net.Dns.GetHostEntry(ipAdress).HostName
host = myHost.Split(".")
Return host(0).ToString()
End Function
End Class
Grüsse
Gianni