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


Python System.get_service方法代码示例

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


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

示例1: copypasta

# 需要导入模块: from winappdbg import System [as 别名]
# 或者: from winappdbg.System import get_service [as 别名]
def copypasta(action, params, wait_state, doing_verb, done_verb):
    'common code in a lot of methods here :)'
    try:
        target = params[0]

        # Do the requested action.
        status = System.get_service(target)
        try:
            name = System.get_service_display_name(target)
        except WindowsError:
            name = target
        print "%s service \"%s\"..." % (doing_verb, name)
        action(*params)

        # Wait for it to finish.
        timeout = 20
        status = System.get_service(target)
        while status.CurrentState == wait_state:
            timeout -= 1
            if timeout <= 0:
                print "Error: timed out."
                return
            time.sleep(0.5)
            status = System.get_service(target)

        # Done.
        print "Service %s successfully." % done_verb

    # On error show a message and quit.
    except WindowsError, e:
        print str(e)
        return
开发者ID:bosskeyproductions,项目名称:winappdbg,代码行数:34,代码来源:service.py

示例2: wait_for_service

# 需要导入模块: from winappdbg import System [as 别名]
# 或者: from winappdbg.System import get_service [as 别名]
def wait_for_service( service, wait_state, timeout = 20 ):
    descriptor = System.get_service( service )
    while descriptor.CurrentState == wait_state:
        timeout -= 1
        if timeout <= 0:
            raise RuntimeException( "Error: timed out." )
        sleep( 0.5 )
        descriptor = System.get_service( service )
开发者ID:hatRiot,项目名称:winappdbg,代码行数:10,代码来源:26_service_restart.py

示例3: restart_service

# 需要导入模块: from winappdbg import System [as 别名]
# 或者: from winappdbg.System import get_service [as 别名]
def restart_service( service ):
    try:

        # Get the display name.
        try:
            display_name = System.get_service_display_name( service )
        except WindowsError:
            display_name = service

        # Get the service descriptor.
        descriptor = System.get_service( service )

        # Is the service running?
        if descriptor.CurrentState != win32.SERVICE_STOPPED:

            # Tell the service to stop.
            print "Stopping service \"%s\"..." % display_name
            System.stop_service( service )

            # Wait for the service to stop.
            wait_for_service( service, win32.SERVICE_STOP_PENDING )
            print "Service stopped successfully."

        # Tell the service to start.
        print "Starting service \"%s\"..." % display_name
        System.start_service( service )

        # Wait for the service to start.
        wait_for_service( service, win32.SERVICE_START_PENDING )
        print "Service started successfully."

        # Show the new process ID.
        # This feature requires Windows XP and above.
        descriptor = System.get_service( service )
        try:
            print "New process ID is: %d" % descriptor.ProcessId
        except AttributeError:
            pass

    # On error, show an error message.
    except WindowsError, e:
        if e.winerror == win32.ERROR_ACCESS_DENIED:
            print "Access denied! Is this an UAC elevated prompt?"
        else:
            print str(e)
开发者ID:hatRiot,项目名称:winappdbg,代码行数:47,代码来源:26_service_restart.py


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