mirror of https://github.com/wh1te909/rmmagent.git
add uninstall
This commit is contained in:
parent
6ec4115730
commit
502cc0d3de
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue