Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

my computer's OS is windows 7, I would like to do this: when my computer's CPU is overrun over 30 minutes, it will trigger task scheduler's event which is send a email to my email account. I don't know how to do this, anyone know it? Thank you for all your kind attention and sorry for my bad English.

share|improve this question

migrated from stackoverflow.com Apr 18 '13 at 12:55

This question came from our site for professional and enthusiast programmers.

    
Use Performance monitor and create an alert for high CPU usage. No programming is needed. (This belongs to Serverfault/Superuser IMHO). –  vonPryz Apr 18 '13 at 6:17
    
If I only use Performance monitor, it can only send a email when the CPU usage is overrun, it means that if my computer's CPU is overrun 30 minutes, it will send many emails to me. –  Nathan L Apr 19 '13 at 5:01

1 Answer 1

It's difficult dealing with a foreign language. I am sure you are doing better than I would with your language.

Assuming you want to send an email if a particular process has been running for more than 30 minutes CPU time,

@ECHO OFF
SETLOCAL
:: get list of tasks which have run more than (time)
SET "overrun="
FOR /f %%i IN ('TASKLIST /fi "cputime gt 00:30:00" ^|FIND /i "dnetc.exe" ') DO SET overrun=Y
IF DEFINED overrun ECHO generate your overrun email

Just change the time to suit and the executable name as required.

Schedule this batch to run as often as you see fit - say every 40 minutes or whatever.

As for how you'd actually send the email, I use BLAT

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.