在床上手机看完电影让电脑关机 休眠 golang源码--配合手机ES浏览器开一个FTP
package main
import (
"io"
"net/http"
"log"
"os/exec"
"fmt"
"time"
)
/*
https://www.cnblogs.com/TianFang/p/7912648.html 封装服务看这里
http://ip/s 手机上浏览器访问这个url 电脑进入休眠
开发者wechat:ipub520
*/
func HelloServer(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "30秒后电脑进入休眠!\n")
time.Sleep(30*time.Second)
c := exec.Command("cmd", "/C", "rundll32.exe powrprof.dll,SetSuspendState 0,1,0", "D:\\a.txt")
if err := c.Run(); err != nil {
fmt.Println("Error: ", err)
}
}
func main() {
http.HandleFunc("/s", HelloServer)
err := http.ListenAndServe(":81", nil)
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}

下载源码文件及exe:
https://files.cnblogs.com/files/ipub520/standby.zip

浙公网安备 33010602011771号