Function Reference


_Net_Share_SessionDel

Ends a network session between a server and a workstation

#include <NetShare.au3>
_Net_Share_SessionDel ( [$sServer = "" [, $sClientName = "" [, $sUserName = ""]]] )

Parameters

$sServer [optional] 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 [optional] Specifies the computer name of the client to disconnect.
If blank, then all the sessions of the user identified by the username parameter will be deleted on the server specified by $sServer.
$sUserName [optional] Specifies the name of the user whose session is to be terminated.
If this parameter is blank, all user sessions from the client specified by the $sClientName parameter are to be terminated.

Return Value

Success: True.
Failure: False.

Remarks

Only members of the Administrators or Server Operators local group can execute this function.
You must pass either $sClientName or $sUserName (or both) for this function to work.

Related

_Net_Share_ShareDel

See Also

Search NetSessionDel in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
        Local $sServer

        ; 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

        ; Delete all our sessions on the server
        _Net_Share_SessionDel($sServer, @ComputerName)
        MemoWrite("Error ...................: " & @error)

        ; 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