tags:

views:

701

answers:

3

Trying to Create a batch file through which I start this program to monitor processes for example at 1 a.m and continues for an hour and than around 2 a.m stops this program and saves the log file to specific location.

START /MAX C:\Procmon.exe

want to do a research on this whether its possible or not. Don't want to put much time on this.

+3  A: 

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.

Iain Hoult
A: 

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.

Richard
Remember that on Vista you have to use `schtasks` instead of `at` to get access to the full task scheduler functionality. Or just use the GUI for that. And what do you mean with "The task scheduler also seems equally as suspect"? `at` *is* an interface to the Windows Task Scheduler. And you don't need to create a second task with `taskkill`, you can just set the task to end after a certain time in the Task Scheduler (see Iain's answer).
Joey
Johannes, thanks for the pointer to the schtasks command, I wasn't aware of that.It's probably not clear from my comment but I've had limited success using the task scheduler, having a nightly process which shuts down a couple of programs running on my development machine if I forget to do so before leaving the office.The scheduled task to run the batch file works fine for a random amount of time before the task stops working and has to be re-created before it will start working again.
Richard
A: 

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

Joey