Files
Win2Linux/pkg/windows/cmd/cmd.go
2026-04-19 12:56:16 +02:00

19 lines
414 B
Go

package cmd
import (
"Win2Linux/pkg/errors"
"fmt"
"os/exec"
"strings"
)
func Execute(c []string) (string, error) {
a := strings.Join(c, " ")
cmd := exec.Command("cmd", "/d", "/c", "chcp 65001>nul && "+a)
out, err := cmd.CombinedOutput()
if err != nil {
return "", errors.New(fmt.Sprintf("failed to run the command: %s: %s", err, out), uint32(cmd.ProcessState.ExitCode()))
}
return string(out), nil
}