Jump to content
Sign in to follow this  
realkiller

computernames

Recommended Posts

sandyd

Use the run command with the following DOS command:

net view | find "\\" > %temp%\computerlist.txt

Then just parse the list to extract the the computer names


----[ SandyD ]---

Share this post


Link to post
Share on other sites
weaponx

Are you wanting a list from a domain?

Share this post


Link to post
Share on other sites
Xenobiologist

#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

Share this post


Link to post
Share on other sites
weaponx

You just set the record for latest reply ever in the history of this forum!

No reply from my question on Aug 29 2007, 1:20 PM until today Today, 4:40 AM!

You must work for a cable company.

Share this post


Link to post
Share on other sites
rasim

realkiller

Nice example from amel27

#include <Array.au3>

Global Const $SV_TYPE_WORKSTATION = 0x1
Global Const $SV_TYPE_SERVER = 0x2
Global Const $SV_TYPE_SQLSERVER = 0x4
Global Const $SV_TYPE_DOMAIN_CTRL = 0x8
Global Const $SV_TYPE_DOMAIN_BAKCTRL = 0x10
Global Const $SV_TYPE_TIME_SOURCE = 0x20
Global Const $SV_TYPE_AFP = 0x40
Global Const $SV_TYPE_NOVELL = 0x80
Global Const $SV_TYPE_DOMAIN_MEMBER = 0x100
Global Const $SV_TYPE_PRINTQ_SERVER = 0x200
Global Const $SV_TYPE_DIALIN_SERVER = 0x400
Global Const $SV_TYPE_XENIX_SERVER = 0x800
Global Const $SV_TYPE_NT = 0x1000
Global Const $SV_TYPE_WFW = 0x2000
Global Const $SV_TYPE_SERVER_MFPN = 0x4000
Global Const $SV_TYPE_SERVER_NT = 0x8000
Global Const $SV_TYPE_POTENTIAL_BROWSER = 0x10000
Global Const $SV_TYPE_BACKUP_BROWSER = 0x20000
Global Const $SV_TYPE_MASTER_BROWSER = 0x40000
Global Const $SV_TYPE_DOMAIN_MASTER = 0x80000
Global Const $SV_TYPE_WINDOWS = 0x400000
Global Const $SV_TYPE_CLUSTER_NT = 0x1000000
Global Const $SV_TYPE_TERMINALSERVER = 0x2000000
Global Const $SV_TYPE_CLUSTER_VS_NT  = 0x4000000
Global Const $SV_TYPE_LOCAL_LIST_ONLY = 0x40000000
Global Const $SV_TYPE_DOMAIN_ENUM = 0x80000000
Global Const $SV_TYPE_ALL = 0xFFFFFFFF

$aCompList = _NetServerEnum($SV_TYPE_WORKSTATION)

_ArrayDisplay($aCompList)

Func _NetServerEnum ($iSrvType = -1, $sDomain = '')
    Local $uBufPtr = DllStructCreate("ptr;int;int"), $res[1]=[0], $i
    Local $uRecord = DllStructCreate("dword;ptr"), $iRecLen = DllStructGetSize($uRecord)
    Local $uString = DllStructCreate("char[16]")
    Local $uDomain = DllStructCreate("byte[32]"), $pDomain = 0
    If Not ($sDomain='' Or $sDomain='*') Then
        DllStructSetData($uDomain, 1, StringToBinary($sDomain,2))
        $pDomain = DllStructGetPtr($uDomain)
    EndIf
    Local $ret = DllCall ("netapi32.dll", "int", "NetServerEnum", _
        "ptr", 0, "int", 100, _
        "ptr", DllStructGetPtr($uBufPtr,1), "int", -1, _
        "ptr", DllStructGetPtr($uBufPtr,2), _
        "ptr", DllStructGetPtr($uBufPtr,3), _
        "int", $iSrvType, "ptr", $pDomain, "int", 0 )
    If $ret[0] Then Return SetError(1, $ret[0], '')
    Local $res[DllStructGetData($uBufPtr,3)+1]=[DllStructGetData($uBufPtr,3)]
    For $i=1 To DllStructGetData($uBufPtr,3)
        Local $uRecord = DllStructCreate("dword;ptr", DllStructGetData($uBufPtr,1)+($i-1)*$iRecLen)
        Local $sNBName = DllStructCreate("byte[32]", DllStructGetData($uRecord,2))
        DllStructSetData($uString,1,BinaryToString(DllStructGetData($sNBName,1),2))
        $res[$i] = DllStructGetData($uString,1)
    Next
    $ret = DllCall ("netapi32.dll", "int", "NetApiBufferFree", "ptr", DllStructGetData($uBufPtr,1))
    Return $res
EndFunc

Share this post


Link to post
Share on other sites
weaponx

For future reference, people will take more consideration for your problem if you reply in a timely manner. We will not take you seriously if you reply 8 months after a response.

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

only if there is one system that collects all computers ever loggedon in your network which you can ask.

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

Share this post


Link to post
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
Sign in to follow this  

×