Fix other
This commit is contained in:
18
pkg/windows/cmd/cmd.go
Normal file
18
pkg/windows/cmd/cmd.go
Normal file
@@ -0,0 +1,18 @@
|
||||
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
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package windows
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -10,8 +11,13 @@ const (
|
||||
MB_OK = 0
|
||||
)
|
||||
|
||||
func Fatal(title, message string, exitCode int) {
|
||||
messageBox(NULL, message, title, MB_OK)
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
|
||||
// MessageBox of Win32 API.
|
||||
func MessageBox(hwnd uintptr, caption, title string, flags uint) int {
|
||||
func messageBox(hwnd uintptr, caption, title string, flags uint) int {
|
||||
_caption, err := syscall.UTF16PtrFromString(caption)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
Reference in New Issue
Block a user