tacticalrmm/_modules/win_agent.py

37 lines
1.0 KiB
Python
Raw Normal View History

2020-03-01 12:20:36 +00:00
from __future__ import absolute_import
import psutil
import os
2020-04-05 09:58:04 +00:00
PROGRAM_DIR = "C:\\Program Files\\TacticalAgent"
2020-03-01 12:20:36 +00:00
def get_services():
return [svc.as_dict() for svc in psutil.win_service_iter()]
def run_python_script(filename, timeout):
python_bin = os.path.join("c:\\salt\\bin", "python.exe")
file_path = os.path.join("c:\\windows\\temp", filename)
__salt__["cp.get_file"](
"salt://scripts/userdefined/{0}".format(filename), file_path
)
return __salt__["cmd.run_all"](
"{0} {1}".format(python_bin, file_path), timeout=timeout
)
2020-03-28 09:54:42 +00:00
def uninstall_agent():
2020-04-05 09:58:04 +00:00
remove_exe = os.path.join(PROGRAM_DIR, "unins000.exe")
2020-03-28 09:54:42 +00:00
__salt__["cmd.run_bg"]([remove_exe, "/VERYSILENT", "/SUPPRESSMSGBOXES"])
return "ok"
def update_salt():
2020-04-05 09:58:04 +00:00
tacrmm = os.path.join(PROGRAM_DIR, "tacticalrmm.exe")
__salt__["cmd.run_bg"]([tacrmm, "-m", "updatesalt"])
2020-04-05 09:58:04 +00:00
return "ok"
def run_manual_checks():
tacrmm = os.path.join(PROGRAM_DIR, "tacticalrmm.exe")
__salt__["cmd.run_bg"]([tacrmm, "-m", "runchecks"])
return "ok"