util_windows.go 317 B

123456789101112131415161718
  1. package shellwords
  2. import (
  3. "errors"
  4. "os"
  5. "os/exec"
  6. "strings"
  7. )
  8. func shellRun(line string) (string, error) {
  9. shell := os.Getenv("COMSPEC")
  10. b, err := exec.Command(shell, "/c", line).Output()
  11. if err != nil {
  12. return "", errors.New(err.Error() + ":" + string(b))
  13. }
  14. return strings.TrimSpace(string(b)), nil
  15. }