Jump to content

how to get all computers in network by name AND ip adress


jennico
 Share

Recommended Posts

hi there,

found some excellent scripts to get network computer names by using net view.

$Line = ""
$get = Run(@ComSpec & " /c net view", @SystemDir, @SW_HIDE, 2)
While $get
    $Line &= StdoutRead($get)
    If @error Then ExitLoop
Wend
$Line = StringSplit(StringStripCR($Line), @LF)
$Out = ""
For $I = 1 To $Line[0]
    If StringLeft($Line[$I], 2) = "\\" then
        $Line[$I] = StringTrimLeft($Line[$I], 2)
        $Out &= StringLeft($Line[$I], StringInStr($Line[$I], Chr(32))) & @CRLF
        MsgBox(0, "Computer", StringLeft($Line[$I], StringInStr($Line[$I], Chr(32))))
    EndIf
Next
MsgBox(0, "Finished", "Finished parsing computer list" & @CRLF & @CRLF & $Out)
ExitoÝ÷ Ù«­¢+Ø¥¹±Õ±ÐíÕ¥1¥ÍÑY¥Ü¹ÔÌÐì(¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì)U%
ÉÑ ÅÕ½Ðí9ÑY¥Ü¥¸1¥ÍÑY¥ÜÅÕ½Ðì°ÔÈÀ°ÔÔÀ°ÄÀÀ°ÄÀÀ°´Ä¤)U%MÑ ­
½±½È ÁàÀÁÁ¤ìÝ¥±°¡¹­É½Õ¹½±½È((ÀÌØí±¥ÍÑÙ¥ÜôU%
Ñɱ
ÉÑ1¥ÍÑY¥Ü ÅÕ½ÐíI¡¹É¹µñ-½µµ¹ÑÈÅÕ½Ðì°ÄÀ°ÄÀ°ÐÀÀ°ÐÔÀ°Õ±Ð°ÀÌØí1YM}a}I%1%9L¤(í}U%
Ñɱ1¥ÍÑY¥Ý}MÑ
½±Õµ¹]¥Ñ  ÀÌØí±¥ÍÑ٥ܰİÀÌØí1YM
]}UQ=M%i}UM!H¤()±½°ÀÌØíÍ}
½µµ¹ÑÍlÅt)±½°ÀÌØíÍ}MÉÙɹµÌô9Ñ}Y¥Ü ¤()½ÈÀÌØí¤ôÀQ¼U   ½Õ¹ ÀÌØíÍ}MÉÙɹµÌ¤´Ä(U%
Ñɱ
ÉÑ1¥ÍÑY¥Ý%Ñ´ ÀÌØíÍ}MÉÙɹµÍlÀÌØí¥tµÀìÌäíðÌäìµÀìÀÌØíÍ}
½µµ¹ÑÍlÀÌØí¥t°ÀÌØí±¥ÍÑ٥ܤ)9áÐ)U%MÑMÑÑ ¤()]¡¥±Ä(MÝ¥Ñ U%Ñ5Í ¤(
ÍÀÌØíU%}Y9Q}
1=M(á¥Ð À¤(¹MÝ¥Ñ )]¹()Õ¹9Ñ}Y¥Ü ¤(1½°ÀÌØíÍ}   ÕôÌäìÌäì(1½°ÀÌØí} ÕôÌäìÌäì(1½°ÀÌØí¥}A¥ôIÕ¸¡
½µMÁµÀìÌäì½¹ÐÙ¥ÜÌäì°ÌäìÌäì°M]}!%°È¬Ð¤(]¡¥±9½ÐÉɽÈ(ÀÌØíÍ}   ÕµÀìôMѽÕÑI ÀÌØí¥}A¥¤(]¹(1½°ÀÌØí¹ÑY¥Ý}1¥¹ÌôMÑÉ¥¹MÁ±¥Ð ÀÌØíÍ}    Õ°1¤(I¥´ÀÌØíÍ}
½µµ¹ÑÍmU  ½Õ¹ ÀÌØí¹ÑY¥Ý}1¥¹Ì¤t(½ÈÀÌØí¤ôÐQ¼U  ½Õ¹ ÀÌØí¹ÑY¥Ý}1¥¹Ì¤´Ä(ÀÌØíÍ}
½µµ¹ÑÍlÀÌØí¤´ÑtôMÑÉ¥¹5¥ ÀÌØí¹ÑY¥Ý}1¥¹ÍlÀÌØí¥t°ÈаÌÀ¤(9áÐ(%5Í   ½à À°ÅÕ½ÐìÅÕ½Ðì°ÀÌØíÍ}Õ¤(ÀÌØí}    ÕôMÑÉ¥¹IáÀ ÀÌØíÍ}  Õ°ÅÕ½ÐìÀäÈìÀäÈìÀäÈìÀäÈì¡lÀ´åµéµhµt¨¤ÅÕ½Ðì°Ì¤(AɽÍÍ
±½Í ÀÌØí¥}A¥¤(IÑÕɸÀÌØí}  Õ)¹Õ¹

i additionally need the corresponding ip adresses in the list. how to add this information ?

sorry, i'm just beginning network experiences.

thx

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

Hi,

I know those scripts :)

Just a fast try:

#include<GuiListView.au3>
#include<Array.au3>
#include<GUIConstantsEx.au3>
#include<ListViewConstants.au3>
GUICreate("NetView in ListView", 520, 550, 100, 100, -1)
GUISetBkColor(0x00E0FFFF)  ; will change background color

$listview = GUICtrlCreateListView("Rechnername|Kommentar|IP", 10, 10, 400, 450, Default, $LVS_EX_GRIDLINES)
_GUICtrlListView_SetColumnWidth($listview, 2, $LVSCW_AUTOSIZE_USEHEADER)

Global $s_Comments[1], $n_IP[1]
Global $s_Servernames = Net_View()

For $i = 0 To UBound($s_Servernames) - 1
    GUICtrlCreateListViewItem($s_Servernames[$i] & '|' & $s_Comments[$i] & '|' & $n_IP[$i], $listview)
Next
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit (0)
    EndSwitch
WEnd

Func Net_View()
    Local $s_Buf = ''
    Local $a_Buf = ''
    Local $i_Pid = Run(@ComSpec & ' /c net view', '', @SW_HIDE, 2 + 4)
    While Not @error
        $s_Buf &= StdoutRead($i_Pid)
    WEnd
    Local $netView_Lines = StringSplit($s_Buf, @LF)
    ReDim $s_Comments[UBound($netView_Lines) ]
    For $i = 4 To UBound($netView_Lines) - 1
        $s_Comments[$i - 4] = StringMid($netView_Lines[$i], 24, 30)
    Next
    $a_Buf = StringRegExp($s_Buf, "\\\\([0-9a-zA-Z-]*)", 3)
    ReDim $n_IP[UBound($a_Buf) ]
    TCPStartup()
    For $i = 1 TO UBound($a_Buf) -1
        $n_IP[$i] = TCPNameToIP($a_Buf[$i])
    Next
    TCPShutdown ( )
    ProcessClose($i_Pid)
    Return $a_Buf
EndFunc   ;==>Net_View

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

TCPNameToIP !!!

sorry, temporarily blind again. :)

thank you mega, i am stupid.

(but, in fact, i wonder that this command works for LAN names, too.)

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

TCPNameToIP !!!

sorry, temporarily blind again. :)

thank you mega, i am stupid.

(but, in fact, i wonder that this command works for LAN names, too.)

j.

Lol, no prob that's what support forum is for.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

.....should be mentioned in help file, shouldn't it ?......

Converts an Internet name to IP address.

TCPNameToIP ( name )

Parameters

name String containing an Internet name.

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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