Board logo

标题: [日期时间] 批处理如何在固定时间段内执行指定程序? [打印本页]

作者: linzuolou    时间: 2013-11-14 22:11     标题: 批处理如何在固定时间段内执行指定程序?

每天的06:00-17:30 时间段内开机执行 c:\a.ex 如果不是这个时间段内就不用执行程序。退出
  1. @echo off
  2. if %time:~0,5% geq 6:00 if %time:~0,5% leq 17:30 goto :hello
  3. exit
  4. :hello
  5. start "" "c:\a.exe"
  6. exit
复制代码
这样写不行。问题出哪里。望指点
作者: apang    时间: 2013-11-14 22:53

set t=%time:~0,5%
if %t: =0% gtr 06:00 if %t: =0% lss 17:00 ...
作者: linzuolou    时间: 2013-11-14 22:58

  多谢指点
作者: foxJL    时间: 2013-11-14 23:08

本帖最后由 foxJL 于 2013-11-15 08:42 编辑
  1. @echo off
  2. set t=%time: =0%
  3. if %t:~0,5% geq 06:00 if %t:~0,5% leq 17:30 goto :hello
  4. exit
  5. :hello
  6. start "" "c:\a.exe"
  7. exit
  8. pause
复制代码

作者: tangqingfu    时间: 2013-11-15 01:05

学习ing,谢谢apang兄和foxJL版主的指点
作者: Batcher    时间: 2013-11-15 07:52

回复 3# linzuolou


    请点击2楼右下角的“评分”按钮




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2