Categories
How to check the status of a service in Python?
You need to check the service in windows and, if necessary, start or stop it. How can this be organized?
Answer the question
In order to leave comments, you need to log in
You can check the status using the psutil library and start/stop using subprocess:
subprocess.call(['sc', 'start', 'service_name']) subprocess.call(['sc', 'stop', 'service_name'])
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question