Python win32service.OpenService() Examples
The following are 11
code examples of win32service.OpenService().
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: ControlService.py From ironpython2 with Apache License 2.0 | 7 votes |
def OnStartCmd(self, id, code): service = self.GetSelService() if not service: return s = win32service.OpenService(self.scm, service[1], win32service.SERVICE_ALL_ACCESS) win32service.StartService(s, None) win32service.CloseServiceHandle(s) self.ReloadData()
Example #2
Source File: win32serviceutil.py From ironpython2 with Apache License 2.0 | 6 votes |
def StopServiceWithDeps(serviceName, machine = None, waitSecs = 30): # Stop a service recursively looking for dependant services hscm = win32service.OpenSCManager(machine,None,win32service.SC_MANAGER_ALL_ACCESS) try: deps = __FindSvcDeps(serviceName) for dep in deps: hs = win32service.OpenService(hscm, dep, win32service.SERVICE_ALL_ACCESS) try: __StopServiceWithTimeout(hs, waitSecs) finally: win32service.CloseServiceHandle(hs) # Now my service! hs = win32service.OpenService(hscm, serviceName, win32service.SERVICE_ALL_ACCESS) try: __StopServiceWithTimeout(hs, waitSecs) finally: win32service.CloseServiceHandle(hs) finally: win32service.CloseServiceHandle(hscm)
Example #3
Source File: utils.py From Fastir_Collector with GNU General Public License v3.0 | 6 votes |
def create_driver_service(logger): """Creates the service for winpmem""" # Must have absolute path here. if hasattr(sys, "frozen"): driver = os.path.join(sys._MEIPASS, get_winpmem_name()) else: driver = os.path.join(os.getcwd(), get_winpmem_name()) h_scm = win32service.OpenSCManager( None, None, win32service.SC_MANAGER_CREATE_SERVICE) try: h_svc = win32service.CreateService( h_scm, "pmem", "pmem", win32service.SERVICE_ALL_ACCESS, win32service.SERVICE_KERNEL_DRIVER, win32service.SERVICE_DEMAND_START, win32service.SERVICE_ERROR_IGNORE, driver, None, 0, None, None, None) except win32service.error, e: logger.error(e) h_svc = win32service.OpenService(h_scm, "pmem", win32service.SERVICE_ALL_ACCESS)
Example #4
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 #5
Source File: live_windows.py From rekall with GNU General Public License v2.0 | 5 votes |
def remove_service(self, also_close_as=True): self.session.logging.debug("Removing service %s", self.plugin_args.service_name) # Make sure the handle is closed. if also_close_as: self.session.physical_address_space.close() # Stop the service if it's running. if not self.hSvc: try: self.hSvc = win32service.OpenService( self.hScm, self.plugin_args.service_name, win32service.SERVICE_ALL_ACCESS) except win32service.error: self.session.logging.debug("%s service does not exist.", self.plugin_args.service_name) if self.hSvc: self.session.logging.debug("Stopping service: %s", self.plugin_args.service_name) try: win32service.ControlService( self.hSvc, win32service.SERVICE_CONTROL_STOP) except win32service.error as e: self.session.logging.debug("Error stopping service: %s", e) self.session.logging.debug("Deleting service: %s", self.plugin_args.service_name) try: win32service.DeleteService(self.hSvc) except win32service.error as e: self.session.logging.debug("Error deleting service: %s", e) win32service.CloseServiceHandle(self.hSvc)
Example #6
Source File: win32serviceutil.py From ironpython2 with Apache License 2.0 | 5 votes |
def SmartOpenService(hscm, name, access): try: return win32service.OpenService(hscm, name, access) except win32api.error, details: if details.winerror not in [winerror.ERROR_SERVICE_DOES_NOT_EXIST, winerror.ERROR_INVALID_NAME]: raise
Example #7
Source File: ControlService.py From ironpython2 with Apache License 2.0 | 5 votes |
def ReloadData(self): service = self.GetSelService() self.listCtrl.SetRedraw(0) self.listCtrl.ResetContent() svcs = win32service.EnumServicesStatus(self.scm) i = 0 self.data = [] for svc in svcs: try: status = ('Unknown', 'Stopped', 'Starting', 'Stopping', 'Running', 'Continuing', 'Pausing', 'Paused')[svc[2][1]] except: status = 'Unknown' s = win32service.OpenService(self.scm, svc[0], win32service.SERVICE_ALL_ACCESS) cfg = win32service.QueryServiceConfig(s) try: startup = ('Boot', 'System', 'Automatic', 'Manual', 'Disabled')[cfg[1]] except: startup = 'Unknown' win32service.CloseServiceHandle(s) # svc[2][2] control buttons pos = self.listCtrl.AddString(str(svc[1]) + '\t' + status + '\t' + startup) self.listCtrl.SetItemData(pos, i) self.data.append(tuple(svc[2]) + (svc[1], svc[0], )) i = i + 1 if service and service[1] == svc[0]: self.listCtrl.SetCurSel(pos) self.OnListEvent(self.IDC_LIST, win32con.LBN_SELCHANGE) self.listCtrl.SetRedraw(1)
Example #8
Source File: ControlService.py From ironpython2 with Apache License 2.0 | 5 votes |
def OnStopCmd(self, id, code): service = self.GetSelService() if not service: return s = win32service.OpenService(self.scm, service[1], win32service.SERVICE_ALL_ACCESS) win32service.ControlService(s, win32service.SERVICE_CONTROL_STOP) win32service.CloseServiceHandle(s) self.ReloadData()
Example #9
Source File: ControlService.py From ironpython2 with Apache License 2.0 | 5 votes |
def OnContinueCmd(self, id, code): service = self.GetSelService() if not service: return s = win32service.OpenService(self.scm, service[1], win32service.SERVICE_ALL_ACCESS) win32service.ControlService(s, win32service.SERVICE_CONTROL_CONTINUE) win32service.CloseServiceHandle(s) self.ReloadData()
Example #10
Source File: ControlService.py From ironpython2 with Apache License 2.0 | 5 votes |
def OnStartupCmd(self, id, code): service = self.GetSelService() if not service: return s = win32service.OpenService(self.scm, service[1], win32service.SERVICE_ALL_ACCESS) if StartupDlg(service[0], s).DoModal() == win32con.IDOK: self.ReloadData()
Example #11
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)