利用Shutdown命令动态输入关键时间

来源:百度知道 编辑:UC知道 时间:2024/06/04 08:22:08
利用一个批处理文件完成
打开批处理输入要多少分钟后关机

最简单的:比如名称为 a.bat 文件内容如下:

@Echo off
shutdown -s -t %1
exit

在执行的时候需要输入 a 100 回车

表示在 100毫秒后关机。

@echo off
color f0
set b=%1
if "%b%"=="q" goto quit
if "%b%"=="0" goto thread
set /a a=%b%
:check
if "%a%"=="0" set /a a=-1
if %a% GEQ 0 goto thread
echo 需要手动输入时间。
set /p b=输入时间(单位:毫秒)
if "%b%"=="q" goto quit
if "%b%"=="0" goto thread
set /a a=%b%
goto check
:thread
shutdown /s /t %a%
set /a a=-1
:quit
pause

保存为bat文件。
或者:

set wshshell = createobject("wscript.shell")
k=wscript.arguments(0)
runa(k)

function runa(a)
if not IsNumeric(a) then
a=inputbox("输入时间(单位:分钟),[取消]或'无输入'退出脚本。")
if a="" then exit function
runa(a)
else
if