Python win32service.SERVICE_STOPPED Examples

The following are 9 code examples of win32service.SERVICE_STOPPED(). 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: win32serviceutil.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
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) 
Example #2
Source File: ControlService.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def OnListEvent(self, id, code):
		if code == win32con.LBN_SELCHANGE or code == win32con.LBN_SELCANCEL:
			pos = self.listCtrl.GetCurSel()
			if pos >= 0:
				data = self.data[self.listCtrl.GetItemData(pos)][2]
				canstart = (self.data[self.listCtrl.GetItemData(pos)][1] == win32service.SERVICE_STOPPED)
			else:
				data = 0
				canstart = 0
			self.GetDlgItem(self.IDC_START).EnableWindow(canstart)
			self.GetDlgItem(self.IDC_STOP).EnableWindow(data & win32service.SERVICE_ACCEPT_STOP)
			self.GetDlgItem(self.IDC_PAUSE).EnableWindow(data & win32service.SERVICE_ACCEPT_PAUSE_CONTINUE)
			self.GetDlgItem(self.IDC_CONTINUE).EnableWindow(data & win32service.SERVICE_ACCEPT_PAUSE_CONTINUE) 
Example #3
Source File: windows_webservice.py    From Chinese-RFID-Access-Control-Library with MIT License 5 votes vote down vote up
def SvcStop(self):
		self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
		cherrypy.engine.exit()
		
		self.ReportServiceStatus(win32service.SERVICE_STOPPED) 
		# very important for use with py2exe
		# otherwise the Service Controller never knows that it is stopped ! 
Example #4
Source File: windows.py    From cloudbase-init with Apache License 2.0 5 votes vote down vote up
def stop_service(self, service_name, wait=False):
        LOG.debug('Stopping service %s', service_name)
        with self._get_service_handle(
                service_name,
                win32service.SERVICE_STOP |
                win32service.SERVICE_QUERY_STATUS) as hs:
            win32service.ControlService(hs, win32service.SERVICE_CONTROL_STOP)
            if wait:
                while True:
                    service_status = win32service.QueryServiceStatusEx(hs)
                    state = service_status['CurrentState']
                    if state == win32service.SERVICE_STOPPED:
                        return
                    time.sleep(.1) 
Example #5
Source File: platform_windows.py    From scalyr-agent-2 with Apache License 2.0 5 votes vote down vote up
def SvcStop(self):
        self.log("Stopping scalyr service")
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        win32event.SetEvent(self._stop_event)
        self.controller.invoke_termination_handler()
        self.ReportServiceStatus(win32service.SERVICE_STOPPED) 
Example #6
Source File: powermonitor.py    From code with MIT License 5 votes vote down vote up
def SvcStop(self):
        self.ReportServiceStatus(svc.SERVICE_STOP_PENDING)
        self.stop()
        self.ReportServiceStatus(svc.SERVICE_STOPPED) 
Example #7
Source File: win32-identd.py    From code with MIT License 5 votes vote down vote up
def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOPPED) 
Example #8
Source File: Create a New Admin account.py    From Python-for-Offensive-PenTest with MIT License 5 votes vote down vote up
def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        self.stop()
        self.ReportServiceStatus(win32service.SERVICE_STOPPED) 
Example #9
Source File: Backdoor-ing Legitmate Windows Service.py    From Python-for-Offensive-PenTest with MIT License 5 votes vote down vote up
def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) #tell the Service Manager that we are planing to stop the serivce
        self.stop()
        self.ReportServiceStatus(win32service.SERVICE_STOPPED) #tell the Service Manager that we are currently stopping the service