Skip to content

Verify if a process is executing and notificate via e-mail on Windows

Hello,

A few days ago my friend need a Visual Basic Script to verify if a process is running and if it is send an e-mail. He asked me for help to code it, and I helped him.

Visual Basic Script to verify if a process is running and notify via e-mail.

Verify if a process is running with Visual Basic Script and shows a window if it is.
[code lang=”vb”]
set service = GetObject (“winmgmts:”)
for each Process in Service.InstancesOf (“Win32_Process”)
If Process.Name = processName then
wscript.echo “Notepad running”
wscript.quit
End If
next
[/code]

Send an e-mail using Visual Basic Script
[code lang=”vb”]
Const username = “USERNAME”
Const password = “PASSWORD”
Const smtpServer = “smtp.gmail.com”
Const port = 465
Const secure = True
Const userFrom = “FROM”
Const userTo = “TO”
Const emailSubject = “Subject”
Const emailText = “Text”

‘== CODE ==

Const cdoSendUsingPickup = 1 ‘Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 ‘Send the message using the network (SMTP over the network).

Const cdoAnonymous = 0 ‘Do not authenticate
Const cdoBasic = 1 ‘basic (clear-text) authentication
Const cdoNTLM = 2 ‘NTLM

Set objMessage = CreateObject(“CDO.Message”)
objMessage.Subject = emailSubject
objMessage.From = userFrom
objMessage.To = userTo
objMessage.TextBody = emailText

‘==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2

‘Name or IP of Remote SMTP Servesr
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = smtpServer

‘Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”) = cdoBasic

‘Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/sendusername”) = username

‘Your password on the SMTP server
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/sendpassword”) = password

‘Server port (typically 25)
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = port

‘Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpusessl”) = secure

‘Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout”) = 60

objMessage.Configuration.Fields.Update

objMessage.Send
[/code]

This two scripts are changed to work together to do what we want and have a config section.

Best Regards,
Matheus

References:
http://wiki.imacros.net/send-email.vbs
http://www.techimo.com/forum/applications-operating-systems/117464-need-vbulletin-script-check-see-if-process-running.html

Published inwindows

3,911 Comments

  1. http://twocreatix.es/
    El equipo de Twocreatix es una consultora con experiencia enfocada en el mercado espanol, que entrega un enfoque integral a quienes valoran la eficiencia, priorizando en los resultados. Descubre todos los detalles en esta pagina.

  2. http://twocreatix.es/
    El equipo de Twocreatix se consolida como una estructura de confianza dedicada al tejido empresarial espanol, que entrega servicios de calidad a quienes buscan resultados, destacandose por en la atencion personalizada. Mas informacion a traves del enlace.

  3. К основным показаниям относятся:
    Получить больше информации – [url=https://vyvod-iz-zapoya-na-domu-sankt-peterburg-8.ru/]www.domen.ru[/url]

  4. EdwardHourb EdwardHourb

    В этой статье представлен занимательный и актуальный контент, который заставит вас задуматься. Мы обсуждаем насущные вопросы и проблемы, а также освещаем истории, которые вдохновляют на действия и изменения. Узнайте, что стоит за событиями нашего времени!
    Читать полностью – [url=https://catsway.ru/alkogol-v-dome-s-koshkoy-skrytaya-ugroza-i-otvetstvennost-vladeltsa/]нарколог на дом самара цены[/url]

  5. RobertDax RobertDax

    Эта обзорная заметка содержит ключевые моменты и факты по актуальным вопросам. Она поможет читателям быстро ориентироваться в теме и узнать о самых важных аспектах сегодня. Получите краткий курс по современной информации и оставайтесь в курсе событий!
    Раскрыть тему полностью – [url=https://newbabe.ru/zdorove/telefon-narkologa-na-dom.html]нарколог на дом цены[/url]

  6. DanielSkipT DanielSkipT

    Реабилитация алкоголиков с поддержкой специалистов в Москве представляет собой важный и сложный процесс, в котором ключевую роль играет профессиональное вмешательство. Программы реабилитации включают в себя не только медицинскую помощь, но и психологическую, социальную и эмоциональную поддержку, что способствует успешному и долгосрочному восстановлению пациента. Такая комплексная помощь является основой эффективного лечения и предотвращения рецидивов.
    Ознакомиться с деталями – https://reabilitacziya-alkogolikov-moskva-1.ru/

  7. http://verkot.es/
    Verkot se consolida como una agencia especializada dedicada al tejido empresarial espanol, que proporciona servicios de calidad a empresas y particulares, destacandose por en la atencion personalizada. Conoce mas a traves del enlace.

  8. http://verkot.es/
    El equipo de Verkot se consolida como una agencia especializada orientada al tejido empresarial espanol, que entrega un acompanamiento profesional a quienes buscan resultados, valorando en los resultados. Mas informacion aqui.

Leave a Reply

Your email address will not be published. Required fields are marked *