go-cmd / cmd

Non-blocking external commands in Go with streaming output
MIT License
918 stars 128 forks source link

How to hide the console window? #103

Closed isensen closed 5 months ago

isensen commented 5 months ago

Hello, when using exec.Command, you can use the following code to hide the console window, may I ask how go-cmd achieve the same effect?

taskCmd := exec.Command("cmd", "/c", "tasklist")
taskCmd .SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
xmapst commented 5 months ago

Hello, when using exec.Command, you can use the following code to hide the console window, may I ask how go-cmd achieve the same effect?

taskCmd := exec.Command("cmd", "/c", "tasklist")
taskCmd .SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
    cmd.Options{
        // ......
        BeforeExec: []func(cmd *exec.Cmd){
            func(cmd *exec.Cmd) {
                cmd.SysProcAttr = &syscall.SysProcAttr{
                    HideWindow:    true,
                }
            },
        },
    }
isensen commented 5 months ago

Hello, when using exec.Command, you can use the following code to hide the console window, may I ask how go-cmd achieve the same effect?

taskCmd := exec.Command("cmd", "/c", "tasklist")
taskCmd .SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
  cmd.Options{
      // ......
      BeforeExec: []func(cmd *exec.Cmd){
          func(cmd *exec.Cmd) {
              cmd.SysProcAttr = &syscall.SysProcAttr{
                  HideWindow:    true,
              }
          },
      },
  }

Thank you