标题: 如何实现定时关机?
[打印本页]
作者: water0
时间: 2009-4-18 07:00
标题: 如何实现定时关机?
由使用者输入时间 格式如9:00
九点后系统自动关机
作者: qwertl
时间: 2009-4-18 09:22
Quote: |
Originally posted by water0 at 2009-4-18 07:00 AM:
由使用者输入时间 格式如9:00
九点后系统自动关机 |
|
at 09:00 Shutdown -s
作者: mmh1
时间: 2009-4-18 09:38
首先要保证服务已经启动了!!!
作者: water0
时间: 2009-4-20 07:10
你写的啥啊!!根本就不能运行
作者: water0
时间: 2009-4-20 07:10
什么服务啊!
作者: lisyofun
时间: 2009-4-20 07:59
乱写的,见笑了.
@echo off&title 自定义关机时间
color 17
mode con: cols=80 lines=25
net start|find /i "Task Scheduler">nul 2>nul||sc config schedule start= Auto>nul 2>nul&net start schedule>nul 2>nul
:b
echo\
for /f "tokens=1,2,3,4 delims=- " %%a in ('date /t') do set name=%%a年%%b月%%c日 %%d
echo.当前时间为%name% %time:~,-6%
set /p var=请以00:00格式输入一个关机时间,要消除之前设定请输入C:
if "%var%"=="" echo 请输入时间&goto b
if /i %var% == C goto c
at %var% shutdown /f /s /t 0 >nul 2>nul
if %errorlevel% EQU 0 goto a
if not %errorlevel% EQU 0 (
echo 格式有误,请重新输入.
)&(
goto b
)
:a
color 1a
echo.系统将在%var%关机.
goto d
:c
at /d /y >nul 2>nul
echo.已清除关机时间.
goto b
:d
pause
作者: applecy
时间: 2009-4-20 08:52
搞那么复杂...
直接
shutdown /s /t 时间单位:毫秒
作者: mangyuan
时间: 2009-4-20 11:30
抄六楼一部分
@echo off &title 定时关机程序
color 1f
mode con: cols=40 lines=20
echo 请输入定时关机时间,格式如21:00:00
set /p t=
at %t% shutdown -s -t 0
echo 已设置定时关机,系统将在%%t自动关机,按任意键推出
pause
作者: whzcy
时间: 2009-4-20 23:25
这是什么意思啊?mode con: cols=40 lines=20
是指40列20行吗?
作者: mangyuan
时间: 2009-4-21 01:46
显示模式: MODE CON[:] [COLS=c] [LINES=n]
C是columns的缩写,columns是列的意思
作者: water0
时间: 2009-5-22 09:34
at %t% shutdown -s -t 0 为啥要在后面家0啊
作者: Hanyeguxing
时间: 2009-5-22 12:22
Quote: |
Originally posted by water0 at 2009-5-22 09:34:
at %t% shutdown -s -t 0 为啥要在后面家0啊 |
|
-t xx
将用于系统关闭的定时器设置为 xx 秒。默认值是 20 秒。
作者: rs369007
时间: 2009-5-25 13:17
c 调用命令行函数——system("shutdown -s");
条件判断
int tmcontrol(void)
{
int crr;
struct time curr_time;
gettime(&curr_time);
crr=curr_time.ti_hour;
if(9==crr)
return 0;
}
工作循环自己写吧 可以使用sleep()函数