v4114
v4114

Reputation: 21

How do I get a batch file execute at a specific time?

I'm trying to create a batch file which starts a program to monitor processes for example at 1 a.m and continues for an hour and then around 2 a.m stops this program and saves the log file to specific location.

START /MAX C:\Procmon.exe

How can I do this?

Upvotes: 2

Views: 6382

Answers (3)

Iain Hoult
Iain Hoult

Reputation: 4005

Will you be running this through windows scheduler, if so you can stop the task running after a period of time, or when you want it to restart it.

Upvotes: 3

Joey
Joey

Reputation: 354386

You shouldn't use a batch file for this. The Windows Task Scheduler is exactly for this kind of task and much more powerful.

Upvotes: 0

Richard Lucas
Richard Lucas

Reputation: 630

If you are lucky enough to not be running on Vista(*) the "AT" command might be of use to you, with this it would be possible to issue the command you describe in your question at 1am.

Then you would schedule a second command using "AT" at 2am to use the "TASKKILL" command to stop the process, if you are happy to have the command terminated with prejudice.

Failing this, write a tiny program which stays resident in memory and executes both the 'start' and 'stop' instructions when it determines it's the correct time to do either.

(*) I've experimented with AT on Vista and it doesn't seem to work for me, your mileage may vary. The task scheduler also seems equally as suspect.

Upvotes: 0

Related Questions