logo NodeSeekbeta

分享一个设置定时关机的懒人脚本

其实如果手快,可以直接输入命令行指令定时关机。

如果不想输入长指令,可以用这个懒人脚本,把代码存成.bat文件就可以执行,只需要输入分钟数就能倒计时关机,不受程序阻止影响。


@echo off
REM Prompt for minutes using PowerShell input dialog
setlocal enabledelayedexpansion

for /f "delims=" %%i in ('powershell -NoProfile -Command "Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::InputBox('Please enter shutdown delay in minutes:', 'Shutdown Timer', '10')"') do set mins=%%i

REM Validate input
set /a test=%mins% >nul 2>&1
if "%mins%"=="" (
    echo [ERROR] No input. Aborted.
    pause
    exit /b
)
if errorlevel 1 (
    echo [ERROR] Invalid input. Numbers only.
    pause
    exit /b
)
if %mins% LSS 1 (
    echo [ERROR] Please enter a positive integer.
    pause
    exit /b
)

set /a seconds=%mins%*60

REM Schedule forced shutdown
shutdown /s /f /t %seconds%
echo [INFO] Shutdown scheduled in %mins% minute(s) (%seconds% seconds).
echo [INFO] To cancel, open CMD and run: shutdown /a
pause

你好啊,陌生人!

我的朋友,看起来你是新来的,如果想参与到讨论中,点击下面的按钮!

📈用户数目📈

目前论坛共有59971位seeker

🎉欢迎新用户🎉