add uninstall

This commit is contained in:
wh1te909 2020-11-22 18:18:23 -08:00
parent 6ec4115730
commit 502cc0d3de
2 changed files with 23 additions and 0 deletions

View File

@ -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)

View File

@ -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()