Go执行一个windows命令行(cmd)命令
Go执行一个windows命令行(cmd)命令
1、生成桌面的所有文件信息
package main
import (
"fmt"
"os/exec"
)
func main() {
c := exec.Command("cmd", "/C", "dir", ">", "C:\\Desktop\\test.txt")
if err := c.Run(); err != nil {
fmt.Println("Error: ", err)
}
}