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

5,914 Comments

  1. Jamescug Jamescug

    Этот документ охватывает важные аспекты медицинской науки, сосредотачиваясь на ключевых вопросах, касающихся здоровья населения. Мы рассматриваем свежие исследования, клинические рекомендации и лучшие практики, которые помогут улучшить качество лечения и профилактики заболеваний. Читатели получат возможность углубиться в различные медицинские дисциплины.
    Посмотреть подробности – [url=https://mdyussh.ru/kapelnitsa-ot-pohmelya-v-kirzhache-kak-ona-pomogaet-i-gde-mozhno-poluchit/]kirzhach clinica plus[/url]

  2. WarrenShown WarrenShown

    В этой статье мы обсудим процесс восстановления после зависимостей, акцентируя внимание на различных методах и подходах к реабилитации. Читатели узнают, как создать план выздоровления и использовать полезные ресурсы для достижения устойчивых изменений.
    Детальнее – [url=http://cook-babie.ru/uslugi-narkologa-na-domu-vyhod-iz-zapoya-detoksikacziya-i-kodirovanie-v-izhevske.html]наркологическая клиника в ижевске[/url]

  3. HarveyJuilt HarveyJuilt

    Обратиться за помощью стоит, если состояние больного ухудшается, человек не может самостоятельно остановить употребление алкоголя, агрессивно ведет себя, жалуется на боли, бессонницу, тревогу, депрессии, рвоту, тремор, сильную интоксикацию или физические симптомы отмены. В таких случаях важно действовать быстро: срочный вызов нарколога на дом снижает риск осложнения, отравления, судорог и последствий длительного запоя.
    Изучить вопрос глубже – [url=https://narkolog-na-dom-kazan21.ru/]нарколог на дом вывод[/url]

  4. true fortune casino [url=https://www.telegra.ph/true-fortune-casino-bonuses-explained-wagering-made-simple-06-11]https://telegra.ph/true-fortune-casino-bonuses-explained-wagering-made-simple-06-11[/url]

  5. RussellFauct RussellFauct

    В этой статье рассматривается комплексный подход к избавлению от зависимости. Читатель узнает, как сочетание физического, психологического и духовного восстановления помогает достичь стойкого выздоровления.
    Где можно узнать подробнее? – [url=https://dom-lady.ru/kogda-muzh-v-zapoe-spokojnyj-plan-dejstvij-dlya-zheny.html]врач нарколог на дом[/url]

  6. 888starz скачать [url=https://slapshady.com/skachayte-888starz-na-iphone-i-nachnite-igrat-v-onlaynkazino-seychas]https://slapshady.com/skachayte-888starz-na-iphone-i-nachnite-igrat-v-onlaynkazino-seychas/[/url]

  7. true fortune casino [url=https://hedgedoc.info.uqam.ca/s/yj2qrcpfg]https://hedgedoc.info.uqam.ca/s/yj2qrcpfg[/url]

  8. RonaldShusy RonaldShusy

    В данной статье мы поговорим о будущем медицины, акцентируя внимание на прорывных разработках и их потенциале. Читатель узнает о новых подходах к лечению, роли искусственного интеллекта и возможностях персонализированной медицины.
    Узнай первым! – [url=https://vsairnav.ru/nachat-s-chistogo-lista-kak-rasplanirovat-god-chtoby-provesti-ego-plodotvorno/]наркологическую помощь в Химках[/url]

  9. This piece is a masterclass in how to write informative content that actually engages the reader, I was hooked from the opening paragraph right through to the conclusion.

  10. StacyChamp StacyChamp

    В этой публикации мы предложим ряд рекомендаций по избавлению от зависимостей и успешному восстановлению. Мы обсудим методы привлечения поддержки и важность самосознания. Эти советы помогут людям вернуться к нормальной жизни и стать на путь выздоровления.
    Связаться за уточнением – [url=https://saturn-tuapse.ru/anonimnaya-chastnaya-narkologicheskaya/]clinica plus в химках[/url]

Leave a Reply

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