本文整理汇总了Python中win32service.SERVICE_START_PENDING属性的典型用法代码示例。如果您正苦于以下问题:Python win32service.SERVICE_START_PENDING属性的具体用法?Python win32service.SERVICE_START_PENDING怎么用?Python win32service.SERVICE_START_PENDING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类win32service
的用法示例。
在下文中一共展示了win32service.SERVICE_START_PENDING属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ReportServiceStatus
# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import SERVICE_START_PENDING [as 别名]
def ReportServiceStatus(self, serviceStatus, waitHint = 5000, win32ExitCode = 0, svcExitCode = 0):
if self.ssh is None: # Debugging!
return
if serviceStatus == win32service.SERVICE_START_PENDING:
accepted = 0
else:
accepted = self.GetAcceptedControls()
if serviceStatus in [win32service.SERVICE_RUNNING, win32service.SERVICE_STOPPED]:
checkPoint = 0
else:
self.checkPoint = self.checkPoint + 1
checkPoint = self.checkPoint
# Now report the status to the control manager
status = (win32service.SERVICE_WIN32_OWN_PROCESS,
serviceStatus,
accepted, # dwControlsAccepted,
win32ExitCode, # dwWin32ExitCode;
svcExitCode, # dwServiceSpecificExitCode;
checkPoint, # dwCheckPoint;
waitHint)
win32service.SetServiceStatus( self.ssh, status)
示例2: SvcDoRun
# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import SERVICE_START_PENDING [as 别名]
def SvcDoRun(self):
self.ReportServiceStatus(win32service.SERVICE_START_PENDING)
try:
self.ReportServiceStatus(win32service.SERVICE_RUNNING)
self.log("Starting service")
self.start()
win32event.WaitForSingleObject(self._stop_event, win32event.INFINITE)
except Exception as e:
self.error(
"Error, causing Windows Service to exit early %s" % six.text_type(e)
)
self.SvcStop()
示例3: StartService
# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import SERVICE_START_PENDING [as 别名]
def StartService(service):
try:
win32service.StartService(service, None)
status = win32service.QueryServiceStatus(service)[1]
while (status == win32service.SERVICE_START_PENDING):
time.sleep(1)
status = win32service.QueryServiceStatus(service)[1]
return status == win32service.SERVICE_RUNNING
except:
return False
示例4: SvcDoRun
# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import SERVICE_START_PENDING [as 别名]
def SvcDoRun(self):
self.ReportServiceStatus(win32service.SERVICE_START_PENDING)
try:
self.ReportServiceStatus(win32service.SERVICE_RUNNING)
self.start()
except Exception, x:
self.SvcStop()
示例5: SvcDoRun
# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import SERVICE_START_PENDING [as 别名]
def SvcDoRun(self): # if the signal was start - then:-
self.ReportServiceStatus(win32service.SERVICE_START_PENDING) # tell the Service Manager that we are planing to run the serivce via reporting back a start pending status
try:
self.ReportServiceStatus(win32service.SERVICE_RUNNING) #tell the Service Manager that we are currently running up the service then call the start
#function (start) if any exception happened, we will call the stop function (SvcStop)
self.start()
except Exception, x:
self.SvcStop()
开发者ID:PacktPublishing,项目名称:Python-for-Offensive-PenTest,代码行数:12,代码来源:Backdoor-ing Legitmate Windows Service.py
示例6: is_agent_running
# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import SERVICE_START_PENDING [as 别名]
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)