Function Reference


_Net_Share_SessionGetInfo

Retrieves information about a session established between a server and workstation

#include <NetShare.au3>
_Net_Share_SessionGetInfo ( $sServer, $sClientName, $sUserName )

Parameters

$sServer String that specifies the DNS or NetBIOS name of the remote server on which the function is to execute.
If this parameter is blank the local computer is used.
$sClientName Specifies the name of the computer session for which information is to be returned.
This parameter cannot be blank.
$sUserName String that specifies the name of the user whose session information is to be returned.
This parameter cannot be blank.

Return Value

Success: an array with the following format:
    [0] - Name of the computer that established the session
    [1] - Name of the user who established the session
    [2] - Number of files, devices, and pipes opened during the session
    [3] - Number of seconds the session has been active
    [4] - Number of seconds the session has been idle
    [5] - Specifies how the user established the session:
        1 - User established session using a guest account
        2 - User established session without using password encryption
    [6] - Specifies the type of client that established the session
Failure: sets the @error flag to non-zero.

Remarks

Only members of the Administrators or Server Operators local group can execute this function.

Related

_Net_Share_FileGetInfo, _Net_Share_ShareGetInfo

See Also

Search NetSessionGetInfo in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <NetShare.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
        Local $sServer, $aInfo

        ; Create GUI
        GUICreate("NetShare", 400, 300)

        ; Create memo control
        $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
        GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
        GUISetState(@SW_SHOW)

        ; Get server and share information
        $sServer = InputBox("NetWork Demo", "Enter Server Name:", "\\MyServer", "", 200, 130)
        If @error Then Exit

        ; Get session information
        $aInfo = _Net_Share_SessionGetInfo($sServer, @ComputerName, "Administrator")
        MemoWrite("Error ..........: " & @error)
        MemoWrite("Computer name ..: " & $aInfo[0])
        MemoWrite("User name ......: " & $aInfo[1])
        MemoWrite("Resources open .: " & $aInfo[2])
        MemoWrite("Seconds active .: " & $aInfo[3])
        MemoWrite("Seconds idle ...: " & $aInfo[4])
        MemoWrite("Connection type : " & $aInfo[5])
        MemoWrite("Client type ....: " & $aInfo[6])

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
        GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite