-2

I've been trying to get a batch to start another batch on a certain date. (specified) I've tried all that I can think of. TIMEOUT does not work for this. Any suggestions? EDIT: I am sorry I didn't include enough information. by "batch" I meant to say batch, as in the language. I need to write a script with the language of batch to execute on a desired date. Say If I wrote this code in batch...

@echo off
:start
start notepad.exe
pause >nul
goto start

... and I wanted it to execute automatically on a specied date, such as November 25th, how would I go about doing so? Thank you for somewhat understanding.

MabeeDev
  • 15
  • 1
  • 7

2 Answers2

0

You could always use Task Scheduler to do the job - that's what it was built for.

You could try

at 23:30 /every:1,4,8,14,16,23,28 "yourbat.bat"

To run yourbat.bat at 23:30 (11:30pm) on the date(s) following the /every: (run each month) or many other options - see

at /?

from the prompt and be prepared to experiment a little.

But if you want to run on a specific day without using task scheduler (although AT simply schedules a job...) then you might add

if not "%date%"=="whateverdateyouwant" goto :eof

at the start of yourbat.bat code (and the target date must be in the same format as the date shown on aecho %date% instruction

But there are endless possibilities - like having a list of dates/times/processes in a file and matching these against the current date/time and using

if "%date%"=="%%A" if "%time%" gtr "%%B" start "" %%C

Where the precise construct depends on a more concrete definition of what you are doing and specification of the date and time formats you are using.

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • Thank you, I will try "if not "%date%"=="date" goto :a" I will report back if it works (I will have to wait until that date) – MabeeDev Apr 01 '13 at 16:32
0

The infinite loop will waste too many system resources. Task Scheduler is a good choice.

schtasks /create /tn "My App" /tr C:\test.bat /sc once /st 00:00:00 /sd 11/25/2013 /ru System
Batcher
  • 167
  • 1
  • Thank you. I'm sorry I could not post results as I have had computer issues (hardware). This appears to have worked for the task I need. Now I just need to redo it. With the new hard drive and all. – MabeeDev Apr 11 '13 at 23:35