Announcement

Collapse
No announcement yet.

Is Service Running

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is Service Running

    Please use the script to know whether a service is running or not.

    Code:
    def IsServiceRunning(serName):
        import os
        proObj = os.popen('TASKLIST /svc /FI "Services eq '+serName+'"')
        runServices = proObj.read()
        return runServices
    
    ## pass your service name as a argument in "print IsServiceRunning('arg-service-name')"
    print IsServiceRunning('Power')


    Sample Output:
    Click image for larger version

Name:	IsServiceRunning.PNG
Views:	1
Size:	4.5 KB
ID:	4773

    Last edited by Purushothaman; 11-04-2016, 01:26 PM.
Working...
X