Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I write NT bat script to run only on certain condition

Status
Not open for further replies.

Tison

Programmer
Joined
May 12, 1999
Messages
216
Location
CH
How do I write an NT batch script that will reschedule itself an hour later ?
ie
If the condition is true, then run script and stop there.
If condition is false , reschedule for 1 hour later.

eg
:START
IF EXIST FILE.FLAG GOTO MAIN
get current time extracting only hours
newtime = current time + 1
AT newtime JOB.BAT
GOTO END

:MAIN
do something

:END

 
Hrmm, I don't know that NT scripting is that smart.

Can you do the reverse? Setup Wincron (cron tab for WinNT) to run something every hour (the at command can't do things every hour, only every day/month), then

if exist file.flag goto main
goto end

:main
kill -f wincron.exe
do stuff

:end

(Ending the wincron.exe process when you want it to stop running a task every hour).

You can setup the login script, or the NT standard AT command, to run WinCron daily if need be.

Wincron is available at [auto] MCSE NT4/W2K
 
Note, you'll need the kill.exe file from the NT resource kit. [auto] MCSE NT4/W2K
 
You could try using the sleep util from BORK Yardyy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top