Answer the question
In order to leave comments, you need to log in
Why is it looking for a file instead of running a command?
Good afternoon. I needed to launch files from under golang. Googled, I realized that there is no way out except for exec. So quickly I googled the start command. Opened cmd.exe launched the software. I also wrote it myself in golang
//windows
log.Print(c[1])
cmd := exec.Command("start", strings.TrimSpace(c[1]))
err := cmd.Start()
if err != nil {
log.Print(err)
}
log.Printf("Waiting for command to finish...")
err = cmd.Wait()
log.Printf("Command finished with error: %v", err)
2016/04/24 16:30:24 commands.go:23: exec: "start": executable file not found in %PATH%
2016/04/24 16:30:24 commands.go:25: Waiting for command to finish...
2016/04/24 16:30:24 commands.go:27: Command finished with error: exec: not started
Answer the question
In order to leave comments, you need to log in
Try
cmd := exec.Command("cmd", "/C", "start", "", strings.TrimSpace(c[1]))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question