1// +build windows
2
3package open
4
5import (
6	"os"
7	"os/exec"
8	"path/filepath"
9	"strings"
10)
11
12var (
13	cmd      = "url.dll,FileProtocolHandler"
14	runDll32 = filepath.Join(os.Getenv("SYSTEMROOT"), "System32", "rundll32.exe")
15)
16
17func cleaninput(input string) string {
18	r := strings.NewReplacer("&", "^&")
19	return r.Replace(input)
20}
21
22func open(input string) *exec.Cmd {
23	return exec.Command(runDll32, cmd, input)
24}
25
26func openWith(input string, appName string) *exec.Cmd {
27	return exec.Command("cmd", "/C", "start", "", appName, cleaninput(input))
28}
29