fix windows cmd waiting
This commit is contained in:
parent
556b667cc0
commit
da632565d5
@ -204,6 +204,10 @@ func (a *App) OpenFileFolder(path string, relative bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) StartFile(path string) 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
|
return err
|
||||||
}
|
}
|
||||||
|
@ -44,21 +44,20 @@ func CmdHelper(hideWindow bool, args ...string) (*exec.Cmd, error) {
|
|||||||
cmd := exec.Command(cmdHelper, args...)
|
cmd := exec.Command(cmdHelper, args...)
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
||||||
//go:custom_build windows cmd.SysProcAttr.HideWindow = hideWindow
|
//go:custom_build windows cmd.SysProcAttr.HideWindow = hideWindow
|
||||||
err = cmd.Start()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return cmd, nil
|
return cmd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Cmd(args ...string) (string, error) {
|
func Cmd(args ...string) (string, error) {
|
||||||
switch platform := runtime.GOOS; platform {
|
switch platform := runtime.GOOS; platform {
|
||||||
case "windows":
|
case "windows":
|
||||||
cmd, err := CmdHelper(false, args...)
|
cmd, err := CmdHelper(true, args...)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
_, err = cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
cmd.Wait()
|
|
||||||
return "", nil
|
return "", nil
|
||||||
case "darwin":
|
case "darwin":
|
||||||
ex, err := os.Executable()
|
ex, err := os.Executable()
|
||||||
|
Loading…
Reference in New Issue
Block a user