launch_browser_windows.go 478 B

12345678910111213141516171819
  1. //+build windows
  2. package token
  3. import (
  4. "fmt"
  5. "os/exec"
  6. "syscall"
  7. )
  8. func getBrowserCmd(url string) *exec.Cmd {
  9. cmd := exec.Command("cmd")
  10. // CmdLine is only defined when compiling for windows.
  11. // Empty string is the cmd proc "Title". Needs to be included because the start command will interpret the first
  12. // quoted string as that field and we want to quote the URL.
  13. cmd.SysProcAttr = &syscall.SysProcAttr{CmdLine: fmt.Sprintf(`/c start "" "%s"`, url)}
  14. return cmd
  15. }