Jump to content
Sign in to follow this  
Jochem

networklist subnet

Recommended Posts

Jochem

I am using till now a script that I found somewhere overhere on the forum to make a networklist:

Func _netwerklist($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   ;==>_netwerklist

but this is not working over subnets. My knowledge is to little to find-out how I can addapt this script to make it work.

Is It possible to make a networklist over subnets?

Share this post


Link to post
Share on other sites
PsaltyDS

I am using till now a script that I found somewhere overhere on the forum to make a networklist:

Func _netwerklist($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   ;==>_netwerklist

but this is not working over subnets. My knowledge is to little to find-out how I can addapt this script to make it work.

Is It possible to make a networklist over subnets?

I think that is a NetBIOS browser service based query that doesn't mean anything across routed interfaces (outside your VLAN or subnet). You might query your Domain Master Browser (PDC in NT, or PDC Emulator in AD) and get some results from other subnets that are part of the same domain, or maybe you have a WINS server, but don't expect complete results from such a buggy whip method.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
99ojo

I think that is a NetBIOS browser service based query that doesn't mean anything across routed interfaces (outside your VLAN or subnet). You might query your Domain Master Browser (PDC in NT, or PDC Emulator in AD) and get some results from other subnets that are part of the same domain, or maybe you have a WINS server, but don't expect complete results from such a buggy whip method.

:D

Hi,

maybe a simple net view does what you want.

;-))

Stefan

Share this post


Link to post
Share on other sites
Jochem

i did it quick and dirty (every subnet is a domain):

For $comp = 1 To 100 Step 1
        $hostch = "ws-c" & $comp & "." & $dom1
        Ping($host)
        If @error = 0 Then
            RunWait(@ComSpec & " /c " & "tasklist /s " & $host & " /U:" & $user & " /p:" & $pw & " > " & $taskpath & $host & $taskfile, "", @SW_HIDE)
        EndIf
    Next

but thanks anyway

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.