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