怎样通过批处理来关机,重启和登出
2020-03-31 10:26 jetwill 阅读(313) 评论(0) 编辑 收藏 举报How do I shut down, restart or log off Windows via a bat file?
The most common ways to use the shutdown command are:
- shutdown -s — Shuts down.
- shutdown -r — Restarts.
- shutdown -l — Logs off.
- shutdown -h — Hibernates.
Note: There is a common pitfall wherein users think -h means "help" (which it does for every other command-line program... except shutdown.exe,
where it means "hibernate"). They then run shutdown -h and accidentally turn off their computers. Watch out for that.
- shutdown -i — "Interactive mode". Instead of performing an action, it displays a GUI dialog.
- shutdown -a — Aborts a previous shutdown command.
The commands above can be combined with these additional options:
- -f — Forces programs to exit. Prevents the shutdown process from getting stuck.
- -t
— Sets the time until shutdown. Use -t 0 to shutdown immediately. - -c
— Adds a shutdown message. The message will end up in the Event Log. - -y — Forces a "yes" answer to all shutdown queries.
I want to make sure some other really good answers are also mentioned along with this one. Here they are in no particular order.
- The -f option from JosephStyons
- Using rundll32 from VonC
- The Run box from Dean
- Remote shutdown from Kip