improve win service get

This commit is contained in:
wh1te909 2020-08-23 02:47:14 +00:00
parent a45656eba9
commit 33a94fdd91
1 changed files with 20 additions and 1 deletions

View File

@ -23,7 +23,26 @@ TEMP_DIR = os.path.join("C:\\Windows", "Temp")
def get_services():
return [svc.as_dict() for svc in psutil.win_service_iter()]
# see https://github.com/wh1te909/tacticalrmm/issues/38
# for why I am manually implementing the svc.as_dict() method of psutil
ret = []
for svc in psutil.win_service_iter():
i = {}
try:
i["display_name"] = svc.display_name()
i["binpath"] = svc.binpath()
i["username"] = svc.username()
i["start_type"] = svc.start_type()
i["status"] = svc.status()
i["pid"] = svc.pid()
i["name"] = svc.name()
i["description"] = svc.description()
except Exception:
continue
else:
ret.append(i)
return ret
def run_python_script(filename, timeout, script_type="userdefined"):