1

我试图弄清楚如何创建一个批处理文件,该批处理文件加载到服务器上并且可以在特定时间关闭 52 个桌面。我了解这将为每台计算机运行:

shutdown –m \\computername01 –s –f –c “The computer will restart, please save all work.” –t 60 
shutdown –m \\computername02 –s –f –c “The computer will restart, please save all work.” –t 60

ETC...

但问题是,我希望能够提供取消关机的选项,以防有人在计划任务时仍在使用计算机。

像这样的工作:

@echo off
echo Your PC will shutdown in 30 seconds! Press CTRL+C to abort.
ping -n 31 127.0.0.1>nul
shutdown –m \\computername01 –s –f –c “The computer will restart, please save all work.” –t 60 
shutdown –m \\computername02 –s –f –c “The computer will restart, please save all work.” –t 60

还是必须是这样的:

@echo off
echo Your PC will shutdown in 30 seconds! Press CTRL+C to abort.
ping -n 31 127.0.0.1>nul
shutdown –m \\computername01 –s –f –c “The computer will restart, please save all work.” –t 60 
@echo off
echo Your PC will shutdown in 30 seconds! Press CTRL+C to abort.
ping -n 31 127.0.0.1>nul
shutdown –m \\computername02 –s –f –c “The computer will restart, please save all work.” –t 60 

任何帮助都会很棒!

4

1 回答 1

0

您可以使用CHOICE等待按键,然后运行shutdown /a​​.

像这样:

@ECHO OFF
ECHO Your computer will shutdown in 60 seconds, press C to abort.
SHUTDOWN –m \\computername01 –s –f –c “The computer will restart, please save all work.” –t 60
CHOICE -c c -n -t 70 -d c
SHUTDOWN -a

这将启动关机计时器,等待用户按 C,然后取消关机。(此外,CHOICE将等待 70 秒,而倒计时 - 60 秒。)

于 2015-03-06T05:02:46.793 回答