Python win32service.SC_MANAGER_CONNECT Examples
The following are 5
code examples of win32service.SC_MANAGER_CONNECT().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32service
, or try the search function
.
Example #1
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def __init__(self,plugin): """ This initializes the class, and saves the plugin reference for use in the new thread. """ self.plugin = plugin self.file = None self.connecting = False self.receiving = False self.sentMessageOnce = True self.receivingTimeout = None try: scmanager = win32service.OpenSCManager(None, None, win32service.SC_MANAGER_CONNECT) self.service = win32service.OpenService(scmanager, MCE_SERVICE_NAME, win32service.SERVICE_START | win32service.SERVICE_QUERY_STATUS) win32service.CloseServiceHandle(scmanager) except: self.service = None
Example #2
Source File: win32serviceutil.py From ironpython2 with Apache License 2.0 | 5 votes |
def QueryServiceStatus(serviceName, machine=None): hscm = win32service.OpenSCManager(machine,None,win32service.SC_MANAGER_CONNECT) try: hs = SmartOpenService(hscm, serviceName, win32service.SERVICE_QUERY_STATUS) try: status = win32service.QueryServiceStatus(hs) finally: win32service.CloseServiceHandle(hs) finally: win32service.CloseServiceHandle(hscm) return status
Example #3
Source File: windows.py From cloudbase-init with Apache License 2.0 | 5 votes |
def _get_service_control_manager( scm_access=win32service.SC_MANAGER_CONNECT): hscm = win32service.OpenSCManager(None, None, scm_access) try: yield hscm finally: win32service.CloseServiceHandle(hscm)
Example #4
Source File: windows.py From cloudbase-init with Apache License 2.0 | 5 votes |
def _get_service_handle(service_name, service_access=win32service.SERVICE_QUERY_CONFIG, scm_access=win32service.SC_MANAGER_CONNECT): with WindowsUtils._get_service_control_manager(scm_access) as hscm: hs = win32service.OpenService(hscm, service_name, service_access) try: yield hs finally: win32service.CloseServiceHandle(hs)
Example #5
Source File: platform_windows.py From scalyr-agent-2 with Apache License 2.0 | 4 votes |
def is_agent_running(self, fail_if_running=False, fail_if_not_running=False): """Returns true if the agent service is running, as determined by this platform implementation. This will optionally raise an Exception with an appropriate error message if the agent is running or not runnning. @param fail_if_running: True if the method should raise an Exception with a platform-specific error message explaining how it determined the agent is running. @param fail_if_not_running: True if the method should raise an Exception with a platform-specific error message explaining how it determined the agent is not running. @type fail_if_running: bool @type fail_if_not_running: bool @return: True if the agent process is already running. @rtype: bool @raise AgentAlreadyRunning @raise AgentNotRunning """ hscm = None hs = None try: hscm = win32service.OpenSCManager( None, None, win32service.SC_MANAGER_CONNECT ) hs = win32serviceutil.SmartOpenService( hscm, _SCALYR_AGENT_SERVICE_, win32service.SERVICE_QUERY_STATUS ) status = win32service.QueryServiceStatusEx(hs) state = status["CurrentState"] is_running = state in ( win32service.SERVICE_RUNNING, win32service.SERVICE_START_PENDING, ) if fail_if_running and is_running: pid = status["ProcessId"] raise AgentAlreadyRunning( "The operating system reports the Scalyr Agent Service is running with " "pid=%d" % pid ) if fail_if_not_running and not is_running: raise AgentNotRunning( "The operating system reports the Scalyr Agent Service is not running" ) return state in ( win32service.SERVICE_RUNNING, win32service.SERVICE_START_PENDING, ) finally: if hs is not None: win32service.CloseServiceHandle(hs) if hscm is not None: win32service.CloseServiceHandle(hscm)