2017-08-02 15:01:21 +00:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
2017-10-04 23:48:00 +00:00
|
|
|
// ExecScript returns a command to execute a script through a shell.
|
2017-08-02 15:01:21 +00:00
|
|
|
func ExecScript(script string) (*exec.Cmd, error) {
|
|
|
|
shell := "cmd"
|
|
|
|
if other := os.Getenv("SHELL"); other != "" {
|
|
|
|
shell = other
|
|
|
|
}
|
2017-08-09 04:52:50 +00:00
|
|
|
script = "\"" + script + "\""
|
2017-08-02 15:01:21 +00:00
|
|
|
cmd := exec.Command(shell, "/C", script)
|
|
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
|
|
|
CmdLine: strings.Join(cmd.Args, " "),
|
|
|
|
}
|
|
|
|
return cmd, nil
|
|
|
|
}
|
2017-10-11 18:57:39 +00:00
|
|
|
|
|
|
|
func SetSysProcAttr(cmd *exec.Cmd) {}
|
|
|
|
|
|
|
|
func KillCommandSubtree(cmd *exec.Cmd) error {
|
|
|
|
return cmd.Process.Kill()
|
|
|
|
}
|