当前位置: 首页>>代码示例>>Python>>正文


Python win32service.OpenService方法代码示例

本文整理汇总了Python中win32service.OpenService方法的典型用法代码示例。如果您正苦于以下问题:Python win32service.OpenService方法的具体用法?Python win32service.OpenService怎么用?Python win32service.OpenService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32service的用法示例。


在下文中一共展示了win32service.OpenService方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: StopServiceWithDeps

# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import OpenService [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:win32serviceutil.py

示例2: create_driver_service

# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import OpenService [as 别名]
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) 
开发者ID:SekoiaLab,项目名称:Fastir_Collector,代码行数:26,代码来源:utils.py

示例3: __init__

# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import OpenService [as 别名]
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 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:19,代码来源:__init__.py

示例4: remove_service

# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import OpenService [as 别名]
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) 
开发者ID:google,项目名称:rekall,代码行数:37,代码来源:live_windows.py

示例5: SmartOpenService

# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import OpenService [as 别名]
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 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:win32serviceutil.py

示例6: ReloadData

# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import OpenService [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:33,代码来源:ControlService.py

示例7: OnStartCmd

# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import OpenService [as 别名]
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() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:ControlService.py

示例8: OnStopCmd

# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import OpenService [as 别名]
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() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:ControlService.py

示例9: OnContinueCmd

# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import OpenService [as 别名]
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() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:ControlService.py

示例10: OnStartupCmd

# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import OpenService [as 别名]
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() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:ControlService.py

示例11: _get_service_handle

# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import OpenService [as 别名]
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) 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:11,代码来源:windows.py


注:本文中的win32service.OpenService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。