fix windows cmd waiting

This commit is contained in:
josc146 2023-12-12 23:48:32 +08:00
parent 556b667cc0
commit da632565d5
2 changed files with 10 additions and 7 deletions

View File

@ -204,6 +204,10 @@ func (a *App) OpenFileFolder(path string, relative bool) error {
}
func (a *App) StartFile(path string) error {
_, err := CmdHelper(true, path)
cmd, err := CmdHelper(true, path)
if err != nil {
return err
}
err = cmd.Start()
return err
}

View File

@ -44,21 +44,20 @@ func CmdHelper(hideWindow bool, args ...string) (*exec.Cmd, error) {
cmd := exec.Command(cmdHelper, args...)
cmd.SysProcAttr = &syscall.SysProcAttr{}
//go:custom_build windows cmd.SysProcAttr.HideWindow = hideWindow
err = cmd.Start()
if err != nil {
return nil, err
}
return cmd, nil
}
func Cmd(args ...string) (string, error) {
switch platform := runtime.GOOS; platform {
case "windows":
cmd, err := CmdHelper(false, args...)
cmd, err := CmdHelper(true, args...)
if err != nil {
return "", err
}
_, err = cmd.CombinedOutput()
if err != nil {
return "", err
}
cmd.Wait()
return "", nil
case "darwin":
ex, err := os.Executable()