Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Detect Determine Session Locked Disconnected ?
In particular, the topic for the function wtsQuerySessionInfo() will be of interest to you; the function returns an array of strings, and element 1 of the array contains a string value that identifies what state the session is in.
Also, look at the help topic for the function wtsProcIdToSessId(), which has sample code showing how to first get the PID of your script's own process and then using that PID value to get your terminal services session ID value so that you can then query the session for information.
Article ID: W17605
Filename: Detect if Session is Locked.txt
File Created: 2014:03:19:09:36:38
Last Updated: 2014:03:19:09:36:38