“关机/r”和“关机/g”有什么区别?

gat*_*eer 26 windows shutdown cmd.exe

shutdown当我偶然发现以下选项描述时,我正在阅读Windows 中命令的一些选项:

/r         Full shutdown and restart the computer.
/g         Full shutdown and restart the computer. After the system is
           rebooted, restart any registered applications.
Run Code Online (Sandbox Code Playgroud)

我以为当 Windows 重新启动时,每个应用程序都会在关机过程中关闭,然后在系统启动时再次启动。

我想到的一些可能的考虑因素是:

  • 从执行一些重新启动技巧的先前版本的 Windows 遗留下来的
  • 暂时覆盖系统配置的默认行为

是这些吗?都不是?

Dav*_*ill 37

什么是shutdown /g

/g选项将重新启动注册为使用RegisterApplicationRestart API重新启动的应用程序。

Windows 重启管理器(在 Windows Vista 中引入)支持正常关闭和重启使用RegisterApplicationRestart API注册重启的应用程序。

此功能由 Windows 更新使用 – 感谢重新启动管理器,当我早上打呵欠到我的台式电脑时,即使在系统重新启动后,我的 Outlook、浏览器窗口、OneNote、Visual Studio 和 Messenger 都排成一行就像我上床睡觉时一样。

假设您想启动这些“重启后自动重启所有东西”重启之一。几周前,我一直在想,您必须编写一个使用 Restart Manager API(例如RmStartSessionRmShutdown)来执行此操作的小应用程序。

然后我突然想到关闭命令必须支持这样做。事实上,它有:

shutdown /g
Run Code Online (Sandbox Code Playgroud)

重新启动 Windows 并重新启动所有已注册的应用程序:shutdown -g

  • 有趣的是,当我的计算机重新启动以进行更新时,它肯定不会将所有内容都放回原处。事实上,它通常*没有*回到我离开的地方。 (7认同)
  • @DavidPostill 相反,它需要 Windows 更新以这种方式执行重新启动,并且应用程序需要自己注册。 (3认同)
  • @KRyan 它需要 Windows 更新才能向重新启动管理器注册应用程序。我想这个功能不再使用了。请记住,这是在 Vista 中引入的。从那时起,Windows Update 发生了很大变化。 (2认同)