wtsLogoffSession

Performs a logoff of the specified session on a terminal server system.

Syntax:

wtsLogoffSession(server,session,wait-flag)

Parameters:

(s) server: This is the name of the terminal server system on which a session will be logged off. The server name should have the leading "\\" characters on it. Passing in an empty string for this parameter will cause the local terminal server system to be used.

(i) session: This is a session id number that identifies the session that is to be logged off.

(i) wait-flag: This is a flag value that can be either @TRUE or @FALSE. A value of @TRUE indicates that this function should wait for the session logoff to complete before returning control to the script. A value of @FALSE indicates that this function should send the logoff request and then return control to the script immediately.

Returns:

(i) Returns @TRUE on success or @FALSE on failure.

 

This function will logoff the specified session on the specified terminal server system. When a session is logged off, all processes that were running under that session will be terminated as if the terminal server user had manually performed a logoff function using the "Start -> Log off..." menu options in their session. The user whose session is being logged off will receive a popup message box that tells them that their session is being logged off. This message box is displayed by the terminal services client program itself on their workstation, and it cannot be detected from within the terminal services session itself.

Example:
;Load 32-bit or 64-bit extender
AddExtender( "WWWTS44I.DLL" , 0, "WWWTS64I.DLL" )

Title01 = 'Test wtsLogoffSession()' ServerSpec = AskLine('Logoff a session','Server','') SessId = AskLine('Logoff a session','Session Id #','') WaitFlag = AskLine('Logoff a session','Wait Flag (1/0)','1') ErrorMode(@OFF) Result = wtsLogoffSession(ServerSpec,SessId,WaitFlag) RC = LastError() ErrorMode(@CANCEL) TempMsg = StrCat('wtsLogoffSession("',ServerSpec,'",',SessId,',',WaitFlag,') RC =',RC,@CRLF) TempMsg = StrCat(TempMsg,@CRLF,@CRLF,'Result = ',Result) Message(Title01,TempMsg) Exit
See Also:

wtsDisconnectSession(), wtsTerminateProcess()