Jump to content
Sign in to follow this  
jguinch

Enum Network connections

Recommended Posts

jguinch

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...

Share this post


Link to post
Share on other sites
spudw2k

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

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  

×