如何在Windows中使用Cygwin执行关机命令

11

如何在 Windows 2003 服务器机器上通过 Cygwin 执行 Windows 关机命令(shutdown -r)?

1个回答

14
// windows xp
shutdown -s -f now

// windows 7
shutdown /r /t 0

这取决于 Windows 的版本。只需要使用 shutdown --help 进行检查,并确定在您的特定版本上要使用哪个选项。

以下是我使用 Cygwin 得到的帮助页面(可能会有变化)。

% shutdown --help
Usage: shutdown [OPTION]... time
Bring the system down.

  -f, --force      Forces the execution.
  -s, --shutdown   The system will shutdown and power off (if supported)
  -r, --reboot     The system will reboot.
  -h, --hibernate  The system will suspend to disk (if supported)
  -p, --suspend    The system will suspend to RAM (if supported)
      --help       Display this help and exit.
      --version    Output version information and exit.

`time' is either the time in seconds or `+' and the time in minutes or a
timestamp in the format `hh:mm' or the word "now" for an immediate action.

To reboot is the default if started as `reboot', to hibernate if started
as `hibernate', to suspend if started as `suspend', to shutdown otherwise.

在我使用的Windows XP上通过Cygwin关闭计算机时,“now”无法识别。 - Sridhar Sarnobat
1
就像@Sridhar-Sarnobat在回答中所说...它是不确定的!只需运行“shutdown --help”并查找您特定版本的正确选项即可。 - Frankie

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接