syscall
syscall.Shutdown()
os/exec
if err := exec.Command("cmd", "/C", "shutdown", "/s").Run(); err != nil {
fmt.Println("Failed to initiate shutdown:", err)
}
shutdown /ashutdownshutdown /t 0 /sshutdown /?
ExitWindowsEx()0x08Shuts down the system and turns off the power.
user32 := syscall.MustLoadDLL("user32")
defer user32.Release()
exitwin := user32.MustFindProc("ExitWindowsEx")
r1, _, err := exitwin.Call(0x08, 0)
if r1 != 1 {
fmt.Println("Failed to initiate shutdown:", err)
}
SE_SHUTDOWN_NAMEExitWindowsEx()
Failed to initiate shutdown: A required privilege is not held by the client.