github.imxd.top/hashicorp/consul@v1.4.5/agent/exec/exec_windows.go (about) 1 // +build windows 2 3 package exec 4 5 import ( 6 "os" 7 "os/exec" 8 "strings" 9 "syscall" 10 ) 11 12 // Script returns a command to execute a script through a shell. 13 func Script(script string) (*exec.Cmd, error) { 14 shell := "cmd" 15 if other := os.Getenv("SHELL"); other != "" { 16 shell = other 17 } 18 script = "\"" + script + "\"" 19 cmd := exec.Command(shell, "/C", script) 20 cmd.SysProcAttr = &syscall.SysProcAttr{ 21 CmdLine: strings.Join(cmd.Args, " "), 22 } 23 return cmd, nil 24 } 25 26 func SetSysProcAttr(cmd *exec.Cmd) {} 27 28 func KillCommandSubtree(cmd *exec.Cmd) error { 29 return cmd.Process.Kill() 30 }