diff --git a/agent/agent_windows.go b/agent/agent_windows.go index e3e74aa..05191c6 100644 --- a/agent/agent_windows.go +++ b/agent/agent_windows.go @@ -742,6 +742,16 @@ func (a *WindowsAgent) AgentUpdate(url, inno, version string) { cmd.Start() } +func (a *WindowsAgent) AgentUninstall() { + tacUninst := filepath.Join(a.ProgramDir, "unins000.exe") + args := []string{"/C", tacUninst, "/VERYSILENT", "/SUPPRESSMSGBOXES"} + cmd := exec.Command("cmd.exe", args...) + cmd.SysProcAttr = &windows.SysProcAttr{ + CreationFlags: windows.DETACHED_PROCESS | windows.CREATE_NEW_PROCESS_GROUP, + } + cmd.Start() +} + // CleanupPythonAgent cleans up files from the old python agent if this is an upgrade func (a *WindowsAgent) CleanupPythonAgent() { cderr := os.Chdir(a.ProgramDir) diff --git a/agent/rpc_windows.go b/agent/rpc_windows.go index 20ae17c..b1ec3fd 100644 --- a/agent/rpc_windows.go +++ b/agent/rpc_windows.go @@ -147,6 +147,19 @@ func (a *WindowsAgent) RunRPC() { ret.Encode("ok") msg.Respond(resp) }() + + case "uninstall": + go func() { + var resp []byte + ret := codec.NewEncoderBytes(&resp, new(codec.MsgpackHandle)) + ret.Encode("ok") + msg.Respond(resp) + a.AgentUninstall() + + }() + nc.Flush() + nc.Close() + os.Exit(0) } }) nc.Flush()