0

I have a python script which i am using as a service.I have converted the script to .exe for windows and i am starting the service by running the .exe file.

If i once again click on the .exe file,a new instance of the same service starts.Is there a way to tell that a particular service is already running and not allowing the a new instance to start?

amit_183
  • 961
  • 3
  • 19
  • 36

1 Answers1

0

You can list running processes and exit your program if you see that its process name already exists.

import wmi
c = wmi.WMI ()

for process in c.Win32_Process ():
  print process.ProcessId, process.Name
theAlse
  • 5,577
  • 11
  • 68
  • 110