From 4bd3886adcf4a66b8e2388f101b9c440ba811061 Mon Sep 17 00:00:00 2001 From: chengziqing Date: Thu, 8 Nov 2018 13:29:21 +0800 Subject: [PATCH] hide cmd window --- open/exec_windows.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/open/exec_windows.go b/open/exec_windows.go index 2d93617..59f56b0 100644 --- a/open/exec_windows.go +++ b/open/exec_windows.go @@ -7,6 +7,7 @@ import ( "os/exec" "path/filepath" "strings" + "syscall" ) var ( @@ -20,9 +21,13 @@ func cleaninput(input string) string { } func open(input string) *exec.Cmd { - return exec.Command(runDll32, cmd, input) + cmd := exec.Command(runDll32, cmd, input) + cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} + return cmd } func openWith(input string, appName string) *exec.Cmd { - return exec.Command("cmd", "/C", "start", "", appName, cleaninput(input)) + cmd := exec.Command("cmd", "/C", "start", "", appName, cleaninput(input)) + cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} + return cmd }