首页 > 代码库 > golang调用EXE

golang调用EXE

我是win7+go1.7+liteide,调用calc.exe

package mainimport (    "os/exec")func main() {    datapath := "C:/Windows/System32/calc.exe"    cmd := exec.Command("cmd.exe", "/c", "start "+datapath)    cmd.Run()}

package mainimport(    "fmt"    "os/exec")func main(){       c := exec.Command("cmd", "/C", "del", "D:\\a.txt")    if err := c.Run(); err != nil {        fmt.Println("Error: ", err)    }  }

package mainimport (    "fmt"    "os/exec")func main() {    f, err := exec.LookPath("ls")    if err != nil {        fmt.Println(err)    }    fmt.Println(f) //  /bin/ls}

 

 

 

package mainimport (    "os/exec")func main() {    datapath := "C:/Windows/System32/calc.exe"    cd := exec.Command(datapath)    cd.Start()}

golang调用EXE