improve win service get
@@ -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"):
