在Windows中从Golang启动新的命令窗口 [英] Launching a new command window from Golang in Windows
问题描述
我正在编写一个只使用命令窗口(CMD)进行用户输入和输出的应用程序。我需要启动另一个使用自己窗口的应用程序实例。
我试图使用os / exec包,但只创建一个GUI窗口应用。我尝试使用 cmd / c ___
执行应用程序,但它仍未创建单独的窗口。
是有一种方法可以用它自己的窗口,stdin和stdout启动一个非GUI应用程序吗?
我找到了它! p>诀窍是在 cmd / c
之后使用start作为命令
以下是代码:
cmd:= exec.Command(cmd,/ C,start ,_path_to_executable_)
err = cmd.Start()
I'm writing a go application that just uses the command window (CMD) for user input and output. I need to launch another instance of the application that is using its own window.
I trying to use the "os/exec" package but that only creates a window for GUI apps. I tried executing the application with cmd /c ___
but it still hasn't created a separate window.
Is there a way to launch a non-GUI application with its own window, stdin and stdout?
I found it!
The trick is to use the "start" as a command after cmd /c
Here's the code:
cmd:= exec.Command("cmd","/C","start",_path_to_executable_)
err=cmd.Start()
这篇关于在Windows中从Golang启动新的命令窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!