1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
//go:build windows
// +build windows
package util
import (
"strings"
//"fmt"
"os/exec"
"syscall"
)
func NewCommandForWindowsCmd(name string, arg ...string) *Command {
//fmt.Println(arg)
command := new(Command)
command.name = name
// cmd.exe has a unique unquoting algorithm
// provide the full command line in SysProcAttr.CmdLine, leaving Args empty.
// more information: https://golang.org/pkg/os/exec/#Command
command.Cmd = exec.Command(name)
command.Cmd.SysProcAttr = &syscall.SysProcAttr{
HideWindow: false,
CmdLine: strings.Join(arg, " "),
CreationFlags: 0,
}
return command
}
|