我们使用 Powershell Remoting 管理大约 60 台分布式 Windows 7 PC。工作完成后,我们希望计算机关闭:使用 shutdown /s /t X 命令可以轻松完成此操作。但有时当我们发送关机命令时,用户正在积极使用机器,因此如果关机警告提供取消关机的选项会很好。
使用关机命令可以实现这一点吗?还有其他工具可以实现这一点吗?
答案1
从shutdown /?
:
No args Display help. This is the same as typing /?.
/? Display help. This is the same as not typing any options.
/i Display the graphical user interface (GUI).
This must be the first option.
/l Log off. This cannot be used with /m or /d options.
/s Shutdown the computer.
/r Shutdown and restart the computer.
/g Shutdown and restart the computer. After the system is
rebooted, restart any registered applications.
/a Abort a system shutdown.
This can only be used during the time-out period.
/p Turn off the local computer with no time-out or warning.
Can be used with /d and /f options.
/h Hibernate the local computer.
Can be used with the /f option.
/e Document the reason for an unexpected shutdown of a computer.
/m \\computer Specify the target computer.
/t xxx Set the time-out period before shutdown to xxx seconds.
The valid range is 0-315360000 (10 years), with a default of 30.
If the timeout period is greater than 0, the /f parameter is
implied.
/c "comment" Comment on the reason for the restart or shutdown.
Maximum of 512 characters allowed.
/f Force running applications to close without forewarning users.
The /f parameter is implied when a value greater than 0 is
specified for the /t parameter.
/d [p|u:]xx:yy Provide the reason for the restart or shutdown.
p indicates that the restart or shutdown is planned.
u indicates that the reason is user defined.
If neither p nor u is specified the restart or shutdown is
unplanned.
xx is the major reason number (positive integer less than 256).
yy is the minor reason number (positive integer less than 65536).
/t
,/c
是/a
这里感兴趣的选项。
/t
提供超时功能
/a
允许用户取消关机过程等待超时
/c
允许您提供一条消息(/d
影响日志)
可能的解决方案 - 在注释中指出,可以shutdown /a
在超时时间内运行来取消关机。
请考虑向用户发送电子邮件来更详细地描述此事。
另一个解决方案是运行一个简短的脚本,让用户可以选择推迟或授权关机,此时它会等待或运行关机命令。
编辑:在SO上发现了几乎相同的问题,答案如下: 用于关机的批处理文件,带有提示选项以中止它并在一定时间后重新运行?