示例#1
0
def disconnect_session(session_id):
    """
    Disconnect a session.

    .. versionadded:: 2016.11.0

    :param session_id: The numeric Id of the session.
    :return: A boolean representing whether the disconnect succeeded.

    CLI Example:

    .. code-block:: bash

        salt '*' rdp.disconnect_session session_id

        salt '*' rdp.disconnect_session 99
    """
    try:
        win32ts.WTSDisconnectSession(
            win32ts.WTS_CURRENT_SERVER_HANDLE, session_id, True
        )
    except PyWinError as error:
        _LOG.error("Error calling WTSDisconnectSession: %s", error)
        return False
    return True
示例#2
0
 def disconnect(session_id):
     try:
         Logger.debug("perform_disconnect: start logoff %d" % (session_id))
         ret = win32ts.WTSDisconnectSession(None, session_id, True)
         Logger.debug("perform_disconnect: finish disconnect %d ret: %s" %
                      (session_id, str(ret)))
     except Exception:
         Logger.exception("perform_disconnect")
         return False
     return True