M d Y

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


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.

set service = GetObject ("winmgmts:")
for each Process in Service.InstancesOf ("Win32_Process")
        If Process.Name = processName then
                wscript.echo "Notepad running"
        End If

Send an e-mail using Visual Basic Script

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



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

Best Regards,


Comentários do Facebook:


  • By Guilherme H. Haendchen, July 10, 2012 @ 4:02 pm

    Realmente foi útil o script. Obrigado primo ;)

  • By storify.com, May 3, 2014 @ 5:10 am

    Je ѵais fiknir de jwter un coup d'oeil à tout cela dans lla ʝournée

  • By sexy sirène, May 5, 2014 @ 8:43 am

    Voսs publiez sans cesse des articles attractifs

  • By mushybreast9675.soup.io, May 12, 2014 @ 11:14 pm

    Un boո bravo au webmaster du site internet

  • By Neal, May 20, 2014 @ 10:27 am

    Tout ces post sont sincèrement attrayants

  • By massage quick tips, May 22, 2014 @ 11:48 pm

    Good day! Would you mind if I share your blog with my
    facebook group? There's a lot of folks that I think would really enjoy your content.

    Please let me know. Many thanks

  • By meuf pornographique, June 1, 2014 @ 9:01 am

    Encore un bon article : je compte en discuter ce soir avec mes potes

  • By pornographique, June 2, 2014 @ 8:28 am

    Јe finirai de voƿir tout cela dans lla semaine

  • By alojamiento web, June 16, 2014 @ 4:38 pm

    Si deseas deseo de para conseguir mucho de este artículo Poste entonces usted tiene que aplicar
    estas Formas a tu won sitio web .

  • By suceuse de bites demoiselle, June 21, 2014 @ 4:30 pm

    Une fois de plus un splendide poste : je compte en discuter ce soir avec
    certains de mes collègues

  • By Berlin Wall Project, June 25, 2014 @ 6:22 am

    Simply want to saay your article is aas surprising. Thee clarity
    in your podt is simply nice aand i can ssume you're an exoert on this subject.
    Fine with your permission let me to grab your feed to keep updated with forthdoming post.
    Thanks a million and please carry on the enjoyable work.

  • By bf4 emblems xbox one, July 7, 2014 @ 4:14 am

    Appreciation too myy father who told mme oon the topic of this webpage, this webpage is
    really remarkable.

Other Links to this Post

  1. how to do financial planning — July 16, 2014 @ 10:43 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment