I'm trying to download a file and execute it in my windows laptop. My program is well downloaded but when i try to execute it in my code i get this windows error : Your file cannot be executed because the process is busy.
Here is my code :
fmt.Println(stdout)
out, err := os.Create("output.exe")
defer out.Close()
resp, err := http.Get("http://IP:8000/myfile.exe")
defer resp.Body.Close()
n, err := io.Copy(out, resp.Body)
time.Sleep(2 * time.Second)
c := exec.Command("cmd", "/C", "start", "C:\\PATH\\output.exe")
if err := c.Run(); err != nil {
fmt.Println("Error: ", err)
}
I'm pretty new with go. Thanks.