L
L
Luan2018-09-04 17:44:51
Python
Luan, 2018-09-04 17:44:51

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

1 answer(s)
J
JaxxDexx, 2018-09-04
@Luan

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 your question

Ask a Question

731 491 924 answers to any question