Quick question:
I have a python script that will restart a windows service:
import os
import win32serviceutil
serviceName = "Apple Mobile Device"
win32serviceutil.StopService(serviceName)
I need to add several other services.
How would I do that?
Thx
If you want to manually enter them each time do something like this:
import os
import win32serviceutil
stopping = 1
while stopping == 1:
service_name = raw_input('enter the name of the service[s] you would like to stop\nor enter done or exit to exit\n: ')
if service_name.lower() == 'done' or 'exit':
stopping = 2
else:
try:
win32serviceutil.StopService(service_name)
print '{} stopped'.format(service_name)
except:
print 'could not stop service {}'.format(service_name)
elif you want to do it automagically every time you run the function do something more like paidhima:
import wmi
import os
import win32serviceutil
service_name = ['this is service one :)'
,'service 2'
,'service 1 million'
]
for s in service_name:
win32serviceutil.StopService(s)
else you could list all the services and crash your machine by shutting them all down :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With