How do I create a batch file timer to execute / call another batch through out the day Maybe on given times to run but not to run on weekends ? Must run on system times can also be .cmd to run on xp server 2003
如何创建批处理文件计时器以在一天中执行/调用另一批可能在给定时间运行但不在周末运行?必须在系统时间运行也可以.cmd在xp server 2003上运行
8 个解决方案
#1
31
For the timer part of your script i highly reccomend using:
对于脚本的计时器部分,我非常推荐使用:
echo.
echo Waiting For One Hour...
TIMEOUT /T 3600 /NOBREAK
echo.
echo (Put some Other Processes Here)
echo.
pause >nul
This script waits for 1 hour (3600 seconds) and then continues on with the script and the user cannot press any buttons to bypass the timer (besides CTRL+C).
此脚本等待1小时(3600秒),然后继续使用脚本,用户无法按任何按钮绕过计时器(除了CTRL + C)。
You can use
您可以使用
Timeout /t 3600 /nobreak >nul
If you don't want to see a countdown on the screen.
如果您不想在屏幕上看到倒计时。
#2
11
I would use the scheduler (control panel) rather than a cmd line or other application.
我会使用调度程序(控制面板)而不是cmd行或其他应用程序。
Control Panel -> Scheduled tasks
控制面板 - >计划任务
#3
4
Below is a batch file that will wait for 1 minute, check the day, and then perform an action. It uses PING.EXE, but requires no files that aren't included with Windows.
下面是一个等待1分钟的批处理文件,检查当天,然后执行操作。它使用PING.EXE,但不需要Windows中未包含的文件。
@ECHO OFF
:LOOP
ECHO Waiting for 1 minute...
PING -n 60 127.0.0.1>nul
IF %DATE:~0,3%==Mon CALL SomeOtherFile.cmd
IF %DATE:~0,3%==Tue CALL SomeOtherFile.cmd
IF %DATE:~0,3%==Wed CALL SomeOtherFile.cmd
IF %DATE:~0,3%==Thu CALL WootSomeOtherFile.cmd
IF %DATE:~0,3%==Fri CALL SomeOtherFile.cmd
IF %DATE:~0,3%==Sat ECHO Saturday...nothing to do.
IF %DATE:~0,3%==Sun ECHO Sunday...nothing to do.
GOTO LOOP
It could be improved upon in many ways, but it might get you started.
它可以在很多方面得到改进,但它可能会让你开始。
#4
3
The AT command would do that but that's what the Scheduled Tasks gui is for. Enter "help at" in a cmd window for details.
AT命令会这样做,但这就是Scheduled Tasks gui的用途。在cmd窗口中输入“help at”以获取详细信息。
#5
1
I did it by writing a little C# app that just wakes up to launch periodic tasks -- don't know if it is doable from a batch file without downloading extensions to support a sleep command. (For my purposes the Windows scheduler didn't work because the apps launched had no graphics context available.)
我是通过写一个刚刚启动以启动周期性任务的小C#应用程序来做到的 - 不知道它是否可以从批处理文件中执行而不下载扩展以支持睡眠命令。 (就我的目的而言,Windows调度程序不起作用,因为启动的应用程序没有可用的图形上下文。)
#6
1
@echo off
:Start
title timer
color EC
echo Type in an amount of time (Seconds)
set /p time=
color CE
:loop
cls
ping localhost -n 2 >nul
set /a time=%time%-1
echo %time%
if %time% EQU 0 goto Timesup
goto loop
:Timesup
title Time Is Up!
ping localhost -n 2 >nul
ping localhost -n 2 >nul
cls
echo The Time is up!
pause
cls
echo Thank you for using this software.
pause
goto Web
goto Exit
:Web
rem type ur command here
:Exit
Exit
goto Exit
#7
1
@echo off
:Start # seting a ponter
title timer #name the cmd window to "Timer"
echo Type in an amount of time (Seconds)
set /p A= #wating for input from user
set B=1
cls
:loop
ping localhost -n 2 >nul #pinging your self for 1 second
set /A A=A-B #sets the value A - 1
echo %A% # printing A
if %A% EQU 0 goto Timesup #if A = 0 go to ponter Timesup eles loop it
goto loop
:Timesup #ponter Timesup
cls #clear the screen
MSG * /v "time Is Up!" #makes a pop up saying "time Is Up!"
goto Exit #go to exit
:Exit
#8
0
You could also do this>
你也可以这样做>
@echo off
:loop
set a=60
set /a a-1
if a GTR 1 (
echo %a% minutes remaining...
timeout /t 60 /nobreak >nul
goto a
) else if a LSS 1 goto finished
:finished
::code
::code
::code
pause>nul
Or something like that.
或类似的东西。
#1
31
For the timer part of your script i highly reccomend using:
对于脚本的计时器部分,我非常推荐使用:
echo.
echo Waiting For One Hour...
TIMEOUT /T 3600 /NOBREAK
echo.
echo (Put some Other Processes Here)
echo.
pause >nul
This script waits for 1 hour (3600 seconds) and then continues on with the script and the user cannot press any buttons to bypass the timer (besides CTRL+C).
此脚本等待1小时(3600秒),然后继续使用脚本,用户无法按任何按钮绕过计时器(除了CTRL + C)。
You can use
您可以使用
Timeout /t 3600 /nobreak >nul
If you don't want to see a countdown on the screen.
如果您不想在屏幕上看到倒计时。
#2
11
I would use the scheduler (control panel) rather than a cmd line or other application.
我会使用调度程序(控制面板)而不是cmd行或其他应用程序。
Control Panel -> Scheduled tasks
控制面板 - >计划任务
#3
4
Below is a batch file that will wait for 1 minute, check the day, and then perform an action. It uses PING.EXE, but requires no files that aren't included with Windows.
下面是一个等待1分钟的批处理文件,检查当天,然后执行操作。它使用PING.EXE,但不需要Windows中未包含的文件。
@ECHO OFF
:LOOP
ECHO Waiting for 1 minute...
PING -n 60 127.0.0.1>nul
IF %DATE:~0,3%==Mon CALL SomeOtherFile.cmd
IF %DATE:~0,3%==Tue CALL SomeOtherFile.cmd
IF %DATE:~0,3%==Wed CALL SomeOtherFile.cmd
IF %DATE:~0,3%==Thu CALL WootSomeOtherFile.cmd
IF %DATE:~0,3%==Fri CALL SomeOtherFile.cmd
IF %DATE:~0,3%==Sat ECHO Saturday...nothing to do.
IF %DATE:~0,3%==Sun ECHO Sunday...nothing to do.
GOTO LOOP
It could be improved upon in many ways, but it might get you started.
它可以在很多方面得到改进,但它可能会让你开始。
#4
3
The AT command would do that but that's what the Scheduled Tasks gui is for. Enter "help at" in a cmd window for details.
AT命令会这样做,但这就是Scheduled Tasks gui的用途。在cmd窗口中输入“help at”以获取详细信息。
#5
1
I did it by writing a little C# app that just wakes up to launch periodic tasks -- don't know if it is doable from a batch file without downloading extensions to support a sleep command. (For my purposes the Windows scheduler didn't work because the apps launched had no graphics context available.)
我是通过写一个刚刚启动以启动周期性任务的小C#应用程序来做到的 - 不知道它是否可以从批处理文件中执行而不下载扩展以支持睡眠命令。 (就我的目的而言,Windows调度程序不起作用,因为启动的应用程序没有可用的图形上下文。)
#6
1
@echo off
:Start
title timer
color EC
echo Type in an amount of time (Seconds)
set /p time=
color CE
:loop
cls
ping localhost -n 2 >nul
set /a time=%time%-1
echo %time%
if %time% EQU 0 goto Timesup
goto loop
:Timesup
title Time Is Up!
ping localhost -n 2 >nul
ping localhost -n 2 >nul
cls
echo The Time is up!
pause
cls
echo Thank you for using this software.
pause
goto Web
goto Exit
:Web
rem type ur command here
:Exit
Exit
goto Exit
#7
1
@echo off
:Start # seting a ponter
title timer #name the cmd window to "Timer"
echo Type in an amount of time (Seconds)
set /p A= #wating for input from user
set B=1
cls
:loop
ping localhost -n 2 >nul #pinging your self for 1 second
set /A A=A-B #sets the value A - 1
echo %A% # printing A
if %A% EQU 0 goto Timesup #if A = 0 go to ponter Timesup eles loop it
goto loop
:Timesup #ponter Timesup
cls #clear the screen
MSG * /v "time Is Up!" #makes a pop up saying "time Is Up!"
goto Exit #go to exit
:Exit
#8
0
You could also do this>
你也可以这样做>
@echo off
:loop
set a=60
set /a a-1
if a GTR 1 (
echo %a% minutes remaining...
timeout /t 60 /nobreak >nul
goto a
) else if a LSS 1 goto finished
:finished
::code
::code
::code
pause>nul
Or something like that.
或类似的东西。