Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Windows XP 定時關機批處理腳本 DIY:倒計時、定時、每日、顯示倒計時多模式

編輯:Windows XP 系統介紹

利用系統內建 shutdown.exe (位於 System32) 配合批處理邏輯,自製功能豐富的定時關機工具,無需第三方軟件。

核心命令

  • shutdown -s -t 秒數 -c "提示信息":倒計時關機
  • shutdown -a:取消關機
  • at HH:MM shutdown -s -t 0:定時關機 (需 Schedule 服務)
  • at HH:MM /every:M,T,W,Th,F,S,Su shutdown -s -f:每日定時關機

腳本功能選單

*** WINDOWS XP 快速關機系統 ***
1. 倒計時關機 (輸入時/分/秒)
2. 定時關機 (輸入 HH:MM)
3. 顯示倒計時關機 (實時刷新秒數)
4. 設定每天關機
空格. 取消系統關機/所有計劃任務
Q. 退出

關鍵代碼片段

:aaa  倒計時模式
set /p mytimes=小時數:
set /a mytimes=%mytimes%*3600
set /p mytimef=分鐘數:
set /a mytimef=%mytimef%*60
set /p mytimem=秒數:
set /a mytime=%mytimes%+%mytimef%+%mytimem%
shutdown -s -t %mytime% -c "取消請運行 shutdown -a"

:eee  顯示倒計時模式
set /a mytime=... (同上)
SET wait=ping -n 2 127.0.0.1 ^>^nul
for /l %%n in (%mytime%,-1,0) do (
  cls
  echo 〖%%n秒後自動關機〗
  %wait%
)
shutdown -s -t 0

使用方法

  1. 復制完整代碼至記事本,存為 shutdown.bat。
  2. 雙擊運行,按選單操作。
  3. 需取消時選「空格」執行 shutdown -a 並 at /delete /yes 清除計劃任務。

純批處理實現,透明可控,適合不想安裝額外軟件的用戶。

Copyright © Windows教程網 All Rights Reserved