Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send an email from a windows *.bat file

I am writing a windows batch to get the cpu utilization and check for condition is value is greater than 80. if cpu util greater than 80 , i should get a mail.

Could you please help. i use wmic cpu get "LoadPercentage" | find /V "LoadPercentage"

like image 574
user1954762 Avatar asked Dec 06 '25 16:12

user1954762


1 Answers

You would need to use a 3rd party app to send an email, you could use blat, then the rest of the batch would look like this

for /f %%a in ('wmic cpu get "LoadPercentage" ^| find /V "LoadPercentage"') do (
set p=%%a
goto :BREAK
)

:BREAK
if %p% geq 80 blat -params

You would need to replace the -params with blat's actual arguments, which you can find here.

like image 122
Bali C Avatar answered Dec 09 '25 08:12

Bali C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!