How to hide command prompt window when using Exec in Golang?

后端 未结 3 1107
眼角桃花
眼角桃花 2020-12-16 17:44

say i have the following code, using syscall to hide command line window

process := exec.Command(name         


        
3条回答
  •  春和景丽
    2020-12-16 18:31

    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/

提交回复
热议问题