|  | 
 
| scriptor 银牌会员
 
      
 
 
 积分 1187
 发帖 555
 注册 2006-12-21
 状态 离线
 | 
| 『楼 主』:
 [原创]发一个自动计时的bat
 
使用 LLM 解释/回答一下 
 
 
上次来的时候,有人问怎么让一个程序,在设定的时间后运行,今天我写了一个,发上来,大家一起改进。
 
 @echo off
 :lp
 cls
 echo.
 setlocal enabledelayedexpansion
 echo The time now is: %time%
 echo.
 set si=%time%
 echo Press any key to see the result.....
 pause >nul
 
 ::Select var
 set  th=!si:~0,2!
 rem select hour
 set  tm=!si:~3,2!
 rem select minute
 set  ts=!si:~6,2!
 rem select second
 set  tms=!si:~9,2!
 rem select milisecond
 
 :: add one minute to origin.
 ::这里,你可以自己设定隔多久运行某个程序
 set /a tm%+=1
 
 ::Check output
 if "%tm%" equ "60" (set /a th%+=1)
 ::如果大于60分钟,就将小时数加一
 
 echo.
 echo The latest time is: %th%:%tm%:%ts%
 echo Attention,the xxx program will run at this time!
 pause>nul
 goto :lp
 
 
 
 Last edited by scriptor on 2007-9-14 at 04:07 PM ] 
The last time I came, someone asked how to make a program run after a set time. Today I wrote one and posted it, let's improve it together.
 
 @echo off
 :lp
 cls
 echo.
 setlocal enabledelayedexpansion
 echo The time now is: %time%
 echo.
 set si=%time%
 echo Press any key to see the result.....
 pause >nul
 
 ::Select var
 set  th=!si:~0,2!
 rem select hour
 set  tm=!si:~3,2!
 rem select minute
 set  ts=!si:~6,2!
 rem select second
 set  tms=!si:~9,2!
 rem select milisecond
 
 :: add one minute to origin.
 ::Here, you can set by yourself how long to run a certain program
 set /a tm%+=1
 
 ::Check output
 if "%tm%" equ "60" (set /a th%+=1)
 ::If it is greater than 60 minutes, add one to the hour
 
 echo.
 echo The latest time is: %th%:%tm%:%ts%
 echo Attention,the xxx program will run at this time!
 pause>nul
 goto :lp
 
 
 
 Last edited by scriptor on 2007-9-14 at 04:07 PM ] 
 
 
 |  | 
|  2007-1-13 23:21 |  | 
|  | 
 
| vkill 金牌会员
 
       
 
 
 
 积分 4103
 发帖 1744
 注册 2006-1-20
 来自 甘肃.临泽
 状态 离线
 | 
| 『第 2 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
楼主这样还要看是12小时制或24小时制吧! 
The building owner, this still depends on whether it's a 12-hour system or a 24-hour system, right! 
 
 
 |  | 
|  2007-1-14 03:06 |  | 
|  | 
 
| scriptor 银牌会员
 
      
 
 
 积分 1187
 发帖 555
 注册 2006-12-21
 状态 离线
 | 
| 『第 3 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
哦,对了我忘记了
 
 因为我的就是24机制的
 
 那么我想一下,看要不要改一下
 
Oh, right.I forgot.
 
 Because mine is in 24-hour format.
 
 Then let me think, whether to change it or not.
 
 
 
 |  | 
|  2007-1-14 03:14 |  | 
|  | 
 
| scriptor 银牌会员
 
      
 
 
 积分 1187
 发帖 555
 注册 2006-12-21
 状态 离线
 | 
| 『第 4 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
你发一个12进制的时间格式给我我不知道他的格式
 
 或许就只是多了一个
 
 am 或是 pm吧
 
Please provide the specific content that needs to be translated. As you haven't provided the actual Chinese text to translate yet, I can't perform the translation. Please share the Chinese text that needs to be converted from Chinese to English. 
 
 
 |  | 
|  2007-1-14 03:18 |  | 
|  | 
 
| piaoye0605 新手上路
 
  
 
 
 
 积分 18
 发帖 9
 注册 2007-1-4
 来自 山东
 状态 离线
 |  | 
|  2007-1-15 04:16 |  | 
|  | 
 
| piaoye0605 新手上路
 
  
 
 
 
 积分 18
 发帖 9
 注册 2007-1-4
 来自 山东
 状态 离线
 |  | 
|  2007-1-15 04:16 |  | 
|  | 
 
| frankwz 初级用户
 
   
 
 
 
 积分 41
 发帖 22
 注册 2007-4-12
 状态 离线
 |  | 
|  2007-4-14 09:49 |  | 
|  | 
 
| frankwz 初级用户
 
   
 
 
 
 积分 41
 发帖 22
 注册 2007-4-12
 状态 离线
 |  | 
|  2007-4-14 09:49 |  | 
|  | 
 
| gne 初级用户
 
   
 
 
 积分 77
 发帖 45
 注册 2007-8-3
 状态 离线
 |  | 
|  2007-12-31 20:20 |  | 
|  | 
 
| HAT 版主
 
         
 
 
 
 积分 9023
 发帖 5017
 注册 2007-5-31
 状态 离线
 | 
| 『第 10 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
使用计划任务(at或者schtasks)无法满足要求吗? 
Can the use of scheduled tasks (at or schtasks) not meet the requirements? 
 
 
 
 |  
                  |  
  |  | 
|  2007-12-31 21:04 |  | 
|  | 
 
| everest79 金牌会员
 
       一叶枝头,万树皆春
 
 
 
 积分 2564
 发帖 1127
 注册 2006-12-25
 状态 离线
 | 
| 『第 11 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
计划任务是个风险程序 
Scheduled tasks are a risky program 
 
 
 |  | 
|  2007-12-31 22:54 |  | 
|  | 
 
| qita123456 新手上路
 
  
 
 
 
 积分 12
 发帖 5
 注册 2007-2-27
 状态 离线
 | 
| 『第 12 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
if %time:~0,2% LEQ 5 echo It's time to do something如果时间在5点之前就启动命令
 
if %time:~0,2% LEQ 5 echo It's time to do something 
 
 
 |  | 
|  2008-4-14 15:12 |  | 
|  | 
 
| xuye 初级用户
 
   
 
 
 
 积分 79
 发帖 34
 注册 2008-4-2
 状态 离线
 | 
| 『第 13 楼』:
 [求助]! 帮我看看这个批处理如何修改!!!
 
使用 LLM 解释/回答一下 
 
 
这是我看了别人的批处理后自己制作的一个定时关机bat.
 @mode con cols=90 lines=35&color 1f
 @echo off
 call :cl
 goto input
 :1
 title  定时关机 !  made by:小野
 cls
 echo 当前时间:%date% , %time%
 echo\&echo 请输入定时关机时间。 (需要24小时制,如17:30  :请使用英文标点)&echo\&echo\
 echo 如果要返回菜单功能,按 0 后回车!
 echo.
 set tim=
 set /p tim=请输入关机时间:
 if "\%tim%\"=="\0\" call :cl&goto input
 at %tim% /interactive shutdown -s -c "要取消关机请在功能菜单中选择取消关机功能!!"  >nul
 if errorlevel 1 cls&echo * 输入错误,请重新输入! &goto 1
 echo.
 echo.
 echo.
 echo.
 echo ================设置成功!!!==============================
 echo.
 echo ======关机前记得保存好文档或其他要保存的东东哦!  ^_^=====
 ping -n 2 127.1>nul
 call :cl
 goto input
 :2
 shutdown -a
 cls
 echo.
 echo.
 echo.
 title   取消关机成功!! made by:小野
 echo.
 echo=======================取消关机成功!!!==================
 echo.
 echo.
 echo.
 ping -n 2 127.1>nul
 goto input
 :4
 cls
 title  功能说明    made by: 小野
 echo.
 echo.&echo.&echo.&echo.&echo.&echo.
 echo ※※※※※※※※※※※※※※※※功能说明:※※※※※※※※※※※※※※※※※※※※※※
 echo.
 echo.
 echo ◇◇◇◇定时关机:  定时关机功能只能在同一天内使用,它可以在同一个时间段内输入多个关机时间,系统会自动按时间顺序启动关机时间(即在第一个关机时间被取消后,在第二个关机时间启动会被自动启动,依次类推!)。设定关机时间后可在功能菜单下面的“你设定的关机时间是:”查看设定的关机时间。
 echo.
 echo ◇◇◇◇取消关机:  取消关机是在弹出关机倒计时窗口使用才有效!!在没有弹出窗口之前使用虽然会显示取消关机成功,但实际并没有取消定时关机功能,时间一到还会启动定时关机功能!!
 echo.
 echo ◇◇◇◇退出:      退出程序窗口!!
 echo.
 echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo\&echo.&echo.
 pause
 goto input
 
 :3
 cls&exit
 :input
 cls
 title 功能代码号选择!
 cls
 call :card
 echo\&echo\&echo\
 echo 请输入功能代号:
 echo.
 set sel=
 set /p sel=
 if "\%sel%\"=="" goto input
 call :%sel%
 if errorlevel 1 cls&echo\&echo\&echo\&echo\&echo ========= ☆★输入错误命令,想忽悠在下?!★☆======&call :cl&goto input
 :cl
 for /l %%i in (1,1,40) do (
 echo\
 for /l %%a in (1,1,250) do ver>nul
 )
 goto :eof
 :card
 title      功能菜单!  made by: 小野
 echo\&echo\&echo.
 echo\&echo\&echo                                       功能菜单:
 echo                ▲△△△△△△△△△△△△△△△△△△
 echo                ▲                                  ▲
 echo                ▲        1=定时关机                ▲
 echo                ▲                                  ▲
 echo                ▲         2=取消关机               ▲
 echo                ▲                                  ▲
 echo                ▲          3=退出                  ▲
 echo                ▲                                  ▲
 echo                ▲           4=功能说明             ▲
 echo                ▲                                  ▲
 echo                △△△△△△△△△△△△△△△△△△▲
 echo.
 echo.
 echo.
 echo         (注释:等号左边的为功能代号,请输入左边的的代号!&echo\
 echo               取消关机功能只能在弹出关机倒计时窗口时使用有效!!)
 echo.
 echo.
 echo.
 echo             你设定的关机时间是: %tim%
 
 
 我试了一下定时可以,取消关机也可以,但正如我说明所说的,取消关机必须在弹出关机倒计时窗口是才能取消,有没有办法在设定时间后弹出倒计时窗口之前选择取消关机键能够取消定时关机功能。还有如何修改能够让最后一个语句在设定时间后才在功能菜单中显示。
 最后,我使用这个 bat 发生过这样的是我在时间设定那里同以时一间段设定了两个关机时间而且这两个时间相隔一分钟,在第一个关机时间的时候刚开关机程序正常运行,但关到一半就发生了黒屏现象,电脑不会卡死,却无法退出黒屏,这是什么原因?
 希望各位高手指教一下!!
 还有设定关机时间后即使关机后重启,在到了设定时间也会关机。对吗?
 
This is a scheduled shutdown bat I made by looking at others' batch processing.
 @mode con cols=90 lines=35&color 1f
 @echo off
 call :cl
 goto input
 :1
 title  Scheduled Shutdown! made by: Xiao Ye
 cls
 echo Current time: %date% , %time%
 echo\&echo Please enter the scheduled shutdown time. (Need 24-hour format, such as 17:30 : Please use English punctuation)&echo\&echo\
 echo If you want to return to the menu function, press 0 and then enter!
 echo.
 set tim=
 set /p tim=Please enter the shutdown time:
 if "\%tim%\"=="\0\" call :cl&goto input
 at %tim% /interactive shutdown -s -c "To cancel the shutdown, please select the cancel shutdown function in the function menu!!"  >nul
 if errorlevel 1 cls&echo * Incorrect input, please enter again! &goto 1
 echo.
 echo.
 echo.
 echo.
 echo ================Settings successful!!!==============================
 echo.
 echo ======Remember to save documents or other things that need to be saved before shutdown! ^_^=====
 ping -n 2 127.1>nul
 call :cl
 goto input
 :2
 shutdown -a
 cls
 echo.
 echo.
 echo.
 title   Shutdown canceled successfully! made by: Xiao Ye
 echo.
 echo=======================Shutdown canceled successfully!!!==================
 echo.
 echo.
 echo.
 ping -n 2 127.1>nul
 goto input
 :4
 cls
 title  Function Description    made by: Xiao Ye
 echo.
 echo.&echo.&echo.&echo.&echo.&echo.
 echo ※※※※※※※※※※※※※※※※Function Description:※※※※※※※※※※※※※※※※※※※※※※
 echo.
 echo.
 echo ◇◇◇◇Scheduled Shutdown: The scheduled shutdown function can only be used within the same day. It can enter multiple shutdown times within the same time period, and the system will automatically start the shutdown times in chronological order (that is, after the first shutdown time is canceled, the second shutdown time will be automatically started, and so on!). After setting the shutdown time, you can view the set shutdown time under "The shutdown time you set is: " in the function menu.
 echo.
 echo ◇◇◇◇Cancel Shutdown: Canceling the shutdown is only effective when the shutdown countdown window pops up!! Using it before the window pops up will show that the shutdown is canceled successfully, but the scheduled shutdown function is not actually canceled, and the scheduled shutdown function will still be started when the time comes! !
 echo.
 echo ◇◇◇◇Exit:      Exit the program window! !
 echo.
 echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo\&echo.&echo.
 pause
 goto input
 
 :3
 cls&exit
 :input
 cls
 title Function Code Number Selection!
 cls
 call :card
 echo\&echo\&echo\
 echo Please enter the function code number:
 echo.
 set sel=
 set /p sel=
 if "\%sel%\"=="" goto input
 call :%sel%
 if errorlevel 1 cls&echo\&echo\&echo\&echo\&echo ========= ☆★Incorrect command entered, trying to fool me?!★☆======&call :cl&goto input
 :cl
 for /l %%i in (1,1,40) do (
 echo\
 for /l %%a in (1,1,250) do ver>nul
 )
 goto :eof
 :card
 title      Function Menu! made by: Xiao Ye
 echo\&echo\&echo.
 echo\&echo\&echo                                       Function Menu:
 echo                ▲△△△△△△△△△△△△△△△△△△
 echo                ▲                                  ▲
 echo                ▲        1=Scheduled Shutdown                ▲
 echo                ▲                                  ▲
 echo                ▲         2=Cancel Shutdown               ▲
 echo                ▲                                  ▲
 echo                ▲          3=Exit                  ▲
 echo                ▲                                  ▲
 echo                ▲           4=Function Description             ▲
 echo                ▲                                  ▲
 echo                △△△△△△△△△△△△△△△△△△▲
 echo.
 echo.
 echo.
 echo         (Note: The code number on the left of the equal sign is the function code number, please enter the code number on the left!&echo\
 echo               The cancel shutdown function is only effective when the shutdown countdown window pops up! !)
 echo.
 echo.
 echo.
 echo             The shutdown time you set is: %tim%
 
 I tried it and the timing works, and canceling the shutdown also works, but as I explained, canceling the shutdown can only be done when the shutdown countdown window pops up. Is there a way to cancel the scheduled shutdown function by selecting the cancel shutdown key before the countdown window pops up after setting the time. Also, how to modify it so that the last statement is displayed in the function menu only after the set time.
 Finally, I had such a situation with this bat. I set two shutdown times in the same time period and they were one minute apart. When the first shutdown time came, the shutdown program ran normally, but when it was halfway through the shutdown, a black screen phenomenon occurred. The computer didn't freeze, but couldn't exit the black screen. What's the reason?
 Hope all the masters can give advice!!
 Also, after setting the shutdown time, even if the computer restarts after shutdown, it will still shut down when the set time comes. Is that right?
 
 
 
 |  | 
|  2008-4-14 19:28 |  |