Disconnects the specified session on a terminal server system.
wtsDisconnectSession(server,session,wait-flag)
Parameters:(s) server: This is the name of the terminal server system on which a session will be disconnection. 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 disconnected.
(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 disconnect to complete before returning control to the script. A value of @FALSE indicates that this function should send the disconnect request and then return control to the script immediately.
(i) Returns @TRUE on success or @FALSE on failure.
Notes:
This function will disconnect the specified session on the specified terminal server system. When a session becomes disconnected, it still continues to exist on the terminal server, but the workstation that was running the terminal services client loses its connection to the terminal server system. The user may choose to reconnect to the terminal server system again, and upon successfully authenticating with the same user credentials they should be reconnected to their same session that they were previously disconnected from.
The user whose session is being disconnectd will receive a popup message box that tells them that their session is being disconnected. 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.
;Load 32-bit or 64-bit extender
AddExtender('WWWTS44I.DLL',0,'WWWTS64I.DLL')
Title01 = 'Test wtsDisconnectSession()' ServerSpec = AskLine('Disconnect a session','Server','') SessId = AskLine('Disconnect a session','Session Id #','') WaitFlag = AskLine('Disconnect a session','Wait Flag (1/0)','1') ErrorMode(@OFF) Result = wtsDisconnectSession(ServerSpec,SessId,WaitFlag) RC = LastError() ErrorMode(@CANCEL) TempMsg = StrCat('wtsDisconnectSession("',ServerSpec,'",',SessId,',',WaitFlag,') RC = ',RC,@CRLF) TempMsg = StrCat(TempMsg,@CRLF,@CRLF,'Result = ',Result) Message(Title01,TempMsg) Exit