From 502cc0d3dec6d286cd135cc9ab94d23fc26e5840 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sun, 22 Nov 2020 18:18:23 -0800 Subject: [PATCH] add uninstall --- agent/agent_windows.go | 10 ++++++++++ agent/rpc_windows.go | 13 +++++++++++++ 2 files changed, 23 insertions(+) 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()