Windows locks the running program's file, you cannot delete it when it's running - use "taskkill /F" to kill it proper.
[email protected] a következőt írta (2020. augusztus 14., péntek, 11:02:36 UTC+2): > Hello dear fellow gophers, > > I had a relatively simple yet quite inconvenient issue which I felt the > need to ask here. In my main() function; > > os.Remove("my.exe") // err is nil, my.exe is removed > > works in Windows without any errors, but when I call exec beforehand, I > get access is denied error; > > buffer, err := exec.Command("my.exe", myArgs...).Output() // err is nil > here, I get desired output > os.Remove("my.exe") // remove "C:\\.......\my.exe": Access is denied > > I tried using cmd.Process.Kill(), cmd.Process.Wait(), > cmd.Start()-ioutil.ReadlAll()-cmd.Wait() alternatives as well. I kept > getting no errors until 'Access is denied'. > > I'm using go1.14 linux/amd64 for my compiler and Windows 10 Enterprise > 10.0.18362. > > Thank you. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a168aed6-dbe1-4706-ab7b-c30bd2da83c0n%40googlegroups.com.
