From 7e71a075c3b747a1ea89acf6c6ee5129e87c182a Mon Sep 17 00:00:00 2001 From: silversword411 Date: Fri, 8 Dec 2023 12:45:34 -0500 Subject: [PATCH] Restart TRMM agent if it installs choco --- agent/choco_windows.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/agent/choco_windows.go b/agent/choco_windows.go index f75b15f..5e3bc1d 100644 --- a/agent/choco_windows.go +++ b/agent/choco_windows.go @@ -59,6 +59,15 @@ func (a *Agent) InstallChoco() { result.Installed = true a.rClient.R().SetBody(result).Post(url) + + if result.Installed { + restartScript := "Restart-Service -Name 'tacticalrmm'" + _, _, exitcode, err := a.RunScript(restartScript, "powershell", []string{}, 60, false, []string{}) + if err != nil || exitcode != 0 { + a.Logger.Debugln("Failed to restart TRMM agent service:", err) + // Handle the error or log it as required + } + } } func (a *Agent) InstallWithChoco(name string) (string, error) {