Even the question is very old there are hardly any solutions to all versions without qwinsta / query / tsdiscon, namely all Windows home versions.
However there is an easy powershell version to disconnect a session:
$code = @'
[DllImport("wtsapi32.dll")]
static extern IntPtr WTSOpenServer([MarshalAs(UnmanagedType.LPStr)] String pServerName);
[DllImport("wtsapi32.dll")]
static extern void WTSCloseServer(IntPtr hServer);
[DllImport("Wtsapi32.dll")]
static extern bool WTSDisconnectSession(System.IntPtr hServer, int SessionId, bool bWait);
public static void DisconnectSession (String ServerName, int SessionId)
{
IntPtr serverHandle = WTSOpenServer(ServerName);
WTSDisconnectSession(serverHandle, SessionId, true);
WTSCloseServer(serverHandle);
}
'@
$tstType=Add-Type -name Test -MemberDefinition $code -PassThru
#$tstType::DisconnectSession("localhost", 2)
A session id can be obtained e.g. with getProcesss
. To disconnect (not logoff!) a session use $tstType::DisconnectSession("localhost", 2)
.