Jump to content
Sign in to follow this  
jdelaney

User of a mapped drive

Recommended Posts

You can use WMI/AutoIt:

Set objWMIService = GetObject("winmgmts:" & strComputer & "rootCIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkConnection", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
      WScript.Echo "AccessMask: " & objItem.AccessMask
      WScript.Echo "Caption: " & objItem.Caption
      WScript.Echo "Comment: " & objItem.Comment
      WScript.Echo "ConnectionState: " & objItem.ConnectionState
      WScript.Echo "ConnectionType: " & objItem.ConnectionType
      WScript.Echo "Description: " & objItem.Description
      WScript.Echo "DisplayType: " & objItem.DisplayType
      WScript.Echo "InstallDate: " & WMIDateStringToDate(objItem.InstallDate)
      WScript.Echo "LocalName: " & objItem.LocalName
      WScript.Echo "Name: " & objItem.Name
      WScript.Echo "Persistent: " & objItem.Persistent
      WScript.Echo "ProviderName: " & objItem.ProviderName
      WScript.Echo "RemoteName: " & objItem.RemoteName
      WScript.Echo "RemotePath: " & objItem.RemotePath
      WScript.Echo "ResourceType: " & objItem.ResourceType
      WScript.Echo "Status: " & objItem.Status
      WScript.Echo "UserName: " & objItem.UserName
      WScript.Echo
Next

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

Here you go:

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:" & $strComputer & "")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkConnection", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
    For $objItem In $colItems
        ConsoleWrite("AccessMask: " & $objItem.AccessMask & @CRLF)
        ConsoleWrite("Caption: " & $objItem.Caption & @CRLF)
        ConsoleWrite("Comment: " & $objItem.Comment & @CRLF)
        ConsoleWrite("ConnectionState: " & $objItem.ConnectionState & @CRLF)
        ConsoleWrite("ConnectionType: " & $objItem.ConnectionType & @CRLF)
        ConsoleWrite("Description: " & $objItem.Description & @CRLF)
        ConsoleWrite("DisplayType: " & $objItem.DisplayType & @CRLF)
        ConsoleWrite("InstallDate: " & $objItem.InstallDate & @CRLF)
        ConsoleWrite("LocalName: " & $objItem.LocalName & @CRLF)
        ConsoleWrite("Name: " & $objItem.Name & @CRLF)
        ConsoleWrite("Persistent: " & $objItem.Persistent & @CRLF)
        ConsoleWrite("ProviderName: " & $objItem.ProviderName & @CRLF)
        ConsoleWrite("RemoteName: " & $objItem.RemoteName & @CRLF)
        ConsoleWrite("RemotePath: " & $objItem.RemotePath & @CRLF)
        ConsoleWrite("ResourceType: " & $objItem.ResourceType & @CRLF)
        ConsoleWrite("Status: " & $objItem.Status & @CRLF)
        ConsoleWrite("UserName: " & $objItem.UserName & @CRLF)
        ConsoleWrite( @CRLF)
    Next
Else
    Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_NetworkConnection" )
Endif


Func WMIDateStringToDate($dtmDate)
    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

Thanks to AutoIt-Scriptomatic! :D


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...