How to hide command prompt window when using Exec in Golang?
Instead of hiding the console window, you should be able to prevent it with:
cmd := exec.Command(...)
cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: 0x08000000} // CREATE_NO_WINDOW
There is a better solution, which can run exec.Command()
without spawn a visible window, ( ͡° ͜ʖ ͡°).
Here is my code:
Firstly import "syscall"
cmd_path := "C:\\Windows\\system32\\cmd.exe"
cmd_instance := exec.Command(cmd_path, "/c", "notepad")
cmd_instance.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
cmd_output, err := cmd_instance.Output()
Origin: https://www.reddit.com/r/golang/comments/2c1g3x/build_golang_app_reverse_shell_to_run_in_windows/