|
Answer» Hello
I want to create a script that will simplify mass SCHEDULING I need to do. The script is intended to be running at a Windows 2000 Server platform.
I was thinking of this method:
1. The desired batch script will need to check to current system time.
2. The script will find if this time exists in a provided "Programing" text file (that would be replaced periodicly).
3. The "Programing" (Text) file will be at this format:
21:15 21:45 22:35 23:25 . . . HH:MM
4. The script will run every MINUTE, using Windows task scheduler.
5. If the time exists at the text file, the script will call another (existing) script, if not - it will exit.
My knowledge of batch scripts is very limited, and I'll appriciate any help with creating this script.
King REGARDS, TalHi
I managed to come up with:
set time /t = time findstr "%time%" prog.txt if %errorlevel%==0 ( echo Good! )
This is not doing the job comletely, becouse, when running at the script, the "time /t" command returns the time at the format: "HH:MM:SS.MiliScondes", so it can't find the current time at the "prog.txt" file, which contains the scheduling at the format of "HH:MM" only.
Any toughts?I'm guessing the time format returned from time /t is different for each machine, but that shouldn't be a problem as you only need HOURS and minutes.
Code: [Select]echo off for /f "tokens=1-2 delims=: " %%i in ('time /t') do set tm=%%i:%%j findstr "%tm%" prog.txt if %errorlevel%==0 ( echo Good! )
Good luck. Thanks for your reply, Sidewinder, but this doen't work at all... All I get is a prompt to press any key to continue. No error or any other feedback.
Quote All I get is a prompt to press any key to continue. No error or any other feedback.
That's a bit surprising. There is no pause statement in the snippet, so I'm at a loss where the press any key to continue comes from.
I was unable to duplicate your results running the code from the command prompt.
QuoteThe script will run every minute, using Windows task scheduler
How did the job get on the scheduler? Did you use the Windows GUI or the AT command?
When running from the scheduler are you pointing to the correct location for prog.txt. What was the code in the scheduler under last result? In the scheduler, under Creator, is this the same as your user name and are you logged in when the job runs?
The scheduler has it's own set of quirks, better to get job running from the command line first.
|