windows - 如何通过 bat 文件关闭、重新启动或注销 Windows?

标签 windows batch-file command-line restart shutdown

我一直在使用 Remote Desktop Connection进入工作站。但是在这种环境下,我无法使用开始菜单中的电源选项。我需要一种替代方法来关闭或重新启动。

如何通过命令行控制计算机的电源状态?

最佳答案

最常见的使用方法 shutdown 命令是:

  • shutdown -s — 关闭。
  • shutdown -r — 重新启动。
  • shutdown -l — 注销。
  • shutdown -h — 休眠。

    注意:用户认为 -h 是一个常见的陷阱。表示“帮助”(它为所有其他命令行程序所做的...除了 shutdown.exe ,它表示“休眠”)。然后他们运行 shutdown -h不小心关掉了他们的电脑。小心这一点。

  • shutdown -i ——“互动模式”。它不执行操作,而是显示一个 GUI 对话框。

  • shutdown -a — 中止之前的关机命令。

上述命令可以与这些附加选项结合使用:

  • -f — 强制程序退出。防止关机过程卡住。
  • -t <seconds> — 设置关机前的时间。使用 -t 0立即关闭。
  • -c <message> — 添加关机消息。该消息将最终出现在事件日志中。
  • -y — 对所有关闭查询强制回答"is"。

    注意:此选项未记录在任何官方文档中。它是由 these StackOverflow users 发现的.


我想确保与这个答案一起也提到了其他一些非常好的答案。在这里它们没有特定的顺序。

关于windows - 如何通过 bat 文件关闭、重新启动或注销 Windows?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/162304/

相关文章:

file - Mac打开grep文件列表

windows - 如何从 Windows 命令行上的任务列表输出中提取特定字段

linux - 创建文件 :///URI based on the file's directory (pwd) 的 Unix 命令

c++ - 非阻塞套接字和 send()

python - Windows操作系统中的pathos包

Windows 批处理文件 : if else

windows - 如何为 svn 提交和更新编写批处理文件

windows - 什么是 %0|%0 以及它如何工作?

windows - 多窗口 OpenGL/Glut

windows - 复制 *.ext *.ex_ 不适用于绝对路径