Need to be able to kill a remote session

dayv2005

Member
In our company many users connect to our remote server (terminal server) and then from there they use our apps. Some times if they exit the app it leaves their session hung.

I was wondering if there is a way that i can add something that once they exit our application it shuts down their remote connection?
 
Hi,
if you have the id of the Session then it is simple:
disco = "proshut " + "~"" + PDBNAME("SPORTS"). + "~"" + " -C disconnect " + STRING (current_user).
OS-COMMAND SILENT VALUE(disco).

i hope this helped you out.


rgds
NobbyLK
 
Try this :

PROCEDURE WTSOpenServerA EXTERNAL "WtsApi32.dll":
DEF INPUT PARAMETER pServerName AS MEMPTR.
DEF RETURN PARAMETER hServer AS LONG.
END PROCEDURE.

PROCEDURE WTSLogoffSession EXTERNAL "WtsApi32.dll":
DEF INPUT PARAMETER hServer AS LONG.
DEF INPUT PARAMETER SessionID AS LONG.
DEF INPUT PARAMETER bWait AS BYTE.
DEF RETURN PARAMETER bRes AS BYTE.

END PROCEDURE.

DEF VAR pName AS MEMPTR .
DEF VAR serverHandle AS INT.
DEF VAR lOk AS INT.

DEF VAR cName AS CHAR INIT "<Your TS NetBios Name>".

SET-SIZE(pName) = LENGTH(cName) + 1.
PUT-STRING(pName,1) = cName.

RUN WTSOpenServerA (pName , OUTPUT serverHandle).

SET-SIZE(pName) = 0.

RUN WTSLogoffSession (serverHandle, -1, 0, OUTPUT lOk).
 
Use this one to shutdown the system:

PROCEDURE WTSShutdownSystem EXTERNAL "WtsApi32.dll":
DEF INPUT PARAMETER hServer AS LONG.
DEF INPUT PARAMETER lShutDownFlag AS LONG.
DEF RETURN PARAMETER bResult AS BYTE.
END PROCEDURE.
 
Thanks a million that deff deserves some rep points ;)

Dang must have given you some rep not to long ago it told me to spread the wealth or something.


BTW is there anyway to make it just do that without have that RDP dialog comming up saying you were disconnected?
 
Back
Top