Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launching a new command window from Golang in Windows

Tags:

windows

go

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?

like image 799
Laszlo the Wiz Avatar asked May 12 '15 05:05

Laszlo the Wiz


1 Answers

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()

like image 182
Laszlo the Wiz Avatar answered Nov 15 '22 00:11

Laszlo the Wiz