Home >Backend Development >Golang >How to Launch a Separate Command Window for a Golang Application on Windows?
Question:
In a Go application utilizing the command window for user input and output, how do you launch an additional application instance with its own dedicated command window?
Initial Attempts:
The issue arose when attempts to use the "os/exec" package and execute the application with "cmd /c" failed to create a separate window. This led to the question of whether it was possible to launch a non-GUI application with its own window and accessible input/output.
Solution:
The breakthrough came with the realization that the "start" command could be used following "cmd /c". The updated code below successfully launches the application in a separate window:
<code class="go">cmd := exec.Command("cmd", "/C", "start", _path_to_executable_) err := cmd.Start()</code>
The above is the detailed content of How to Launch a Separate Command Window for a Golang Application on Windows?. For more information, please follow other related articles on the PHP Chinese website!