Jump to content

Enum Network connections


Recommended Posts

Hi !

I'm looking for a way to enum all mapped drives and connections etablished (like the Windows command net use [ENTER])

I don't know how to use the _WinNet_EnumResource() function... Is there a way with it ?

Thank you for your help...

Link to comment
Share on other sites

This info can also be found via WMI.

http://msdn.microsoft.com/en-us/library/aa394220(VS.85).aspx

$host = "."
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $host & "\root\cimv2")
$colItems = $objWMIService.ExecQuery ("SELECT * from Win32_NetworkConnection")
$conn = 0
For $objItem in $colItems
    $conn += 1
    $info = "Name: " & $objItem.Name & @CRLF & "ConnectionState: " & $objItem.ConnectionState & @CRLF & "ConnectionType: " & $objItem.ConnectionType & @CRLF & "LocalName: " & $objItem.LocalName & @CRLF & "RemotePath: " & $objItem.RemotePath
    msgbox(0,"MAP " & $conn,$info)
Next
Edited by spudw2k
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...