{"id":1301,"date":"2012-04-16T12:48:46","date_gmt":"2012-04-16T15:48:46","guid":{"rendered":"http:\/\/wordpress.matbra.com\/?p=1301"},"modified":"2012-04-16T12:50:35","modified_gmt":"2012-04-16T15:50:35","slug":"verificar-se-um-processo-esta-execucao-e-notificar-via-e-mail-no-windows","status":"publish","type":"post","link":"https:\/\/wordpress.matbra.com\/en\/2012\/04\/16\/verificar-se-um-processo-esta-execucao-e-notificar-via-e-mail-no-windows\/","title":{"rendered":"Verify if a process is executing and notificate via e-mail on Windows"},"content":{"rendered":"<p>Hello,<\/p>\n<p>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.<\/p>\n<p><a href='http:\/\/wordpress.matbra.com\/wp-content\/uploads\/checkandemail.zip'>Visual Basic Script to verify if a process is running and notify via e-mail.<\/a><\/p>\n<p><!--more--><\/p>\n<p>Verify if a process is running with Visual Basic Script and shows a window if it is.<br \/>\n[code lang=&#8221;vb&#8221;]<br \/>\nset service = GetObject (&#8220;winmgmts:&#8221;)<br \/>\nfor each Process in Service.InstancesOf (&#8220;Win32_Process&#8221;)<br \/>\n\tIf Process.Name = processName then<br \/>\n\t\twscript.echo &#8220;Notepad running&#8221;<br \/>\n\t\twscript.quit<br \/>\n\tEnd If<br \/>\nnext<br \/>\n[\/code]<\/p>\n<p>Send an e-mail using Visual Basic Script<br \/>\n[code lang=&#8221;vb&#8221;]<br \/>\nConst username = &#8220;USERNAME&#8221;<br \/>\nConst password = &#8220;PASSWORD&#8221;<br \/>\nConst smtpServer = &#8220;smtp.gmail.com&#8221;<br \/>\nConst port = 465<br \/>\nConst secure = True<br \/>\nConst userFrom = &#8220;FROM&#8221;<br \/>\nConst userTo = &#8220;TO&#8221;<br \/>\nConst emailSubject = &#8220;Subject&#8221;<br \/>\nConst emailText = &#8220;Text&#8221;<\/p>\n<p>&#8216;== CODE ==<\/p>\n<p>Const cdoSendUsingPickup = 1 &#8216;Send message using the local SMTP service pickup directory.<br \/>\nConst cdoSendUsingPort = 2 &#8216;Send the message using the network (SMTP over the network). <\/p>\n<p>Const cdoAnonymous = 0 &#8216;Do not authenticate<br \/>\nConst cdoBasic = 1 &#8216;basic (clear-text) authentication<br \/>\nConst cdoNTLM = 2 &#8216;NTLM<\/p>\n<p>Set objMessage = CreateObject(&#8220;CDO.Message&#8221;)<br \/>\nobjMessage.Subject = emailSubject<br \/>\nobjMessage.From = userFrom<br \/>\nobjMessage.To = userTo<br \/>\nobjMessage.TextBody = emailText <\/p>\n<p>&#8216;==This section provides the configuration information for the remote SMTP server.<\/p>\n<p>objMessage.Configuration.Fields.Item _<br \/>\n(&#8220;http:\/\/schemas.microsoft.com\/cdo\/configuration\/sendusing&#8221;) = 2 <\/p>\n<p>&#8216;Name or IP of Remote SMTP Servesr<br \/>\nobjMessage.Configuration.Fields.Item _<br \/>\n(&#8220;http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpserver&#8221;) = smtpServer<\/p>\n<p>&#8216;Type of authentication, NONE, Basic (Base64 encoded), NTLM<br \/>\nobjMessage.Configuration.Fields.Item _<br \/>\n(&#8220;http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpauthenticate&#8221;) = cdoBasic<\/p>\n<p>&#8216;Your UserID on the SMTP server<br \/>\nobjMessage.Configuration.Fields.Item _<br \/>\n (&#8220;http:\/\/schemas.microsoft.com\/cdo\/configuration\/sendusername&#8221;) = username<\/p>\n<p>&#8216;Your password on the SMTP server<br \/>\nobjMessage.Configuration.Fields.Item _<br \/>\n(&#8220;http:\/\/schemas.microsoft.com\/cdo\/configuration\/sendpassword&#8221;) = password<\/p>\n<p>&#8216;Server port (typically 25)<br \/>\nobjMessage.Configuration.Fields.Item _<br \/>\n(&#8220;http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpserverport&#8221;) = port<\/p>\n<p>&#8216;Use SSL for the connection (False or True)<br \/>\nobjMessage.Configuration.Fields.Item _<br \/>\n(&#8220;http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpusessl&#8221;) = secure<\/p>\n<p>&#8216;Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP   server)<br \/>\nobjMessage.Configuration.Fields.Item _<br \/>\n(&#8220;http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpconnectiontimeout&#8221;) = 60<\/p>\n<p>objMessage.Configuration.Fields.Update<\/p>\n<p>objMessage.Send<br \/>\n[\/code]<\/p>\n<p>This two scripts are changed to work together to do what we want and have a config section.<\/p>\n<p>Best Regards,<br \/>\nMatheus<\/p>\n<p>References:<br \/>\n<a href=\"http:\/\/wiki.imacros.net\/send-email.vbs\" target=\"_blank\">http:\/\/wiki.imacros.net\/send-email.vbs<\/a><br \/>\n<a href=\"http:\/\/www.techimo.com\/forum\/applications-operating-systems\/117464-need-vbulletin-script-check-see-if-process-running.html\" target=\"_blank\">http:\/\/www.techimo.com\/forum\/applications-operating-systems\/117464-need-vbulletin-script-check-see-if-process-running.html<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>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<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/wordpress.matbra.com\/en\/2012\/04\/16\/verificar-se-um-processo-esta-execucao-e-notificar-via-e-mail-no-windows\/\">Continue reading<span class=\"screen-reader-text\">Verify if a process is executing and notificate via e-mail on Windows<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[38],"tags":[244,245,243,242],"class_list":["post-1301","post","type-post","status-publish","format-standard","hentry","category-windows","tag-email","tag-processo","tag-script","tag-visual-basic","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/psjGE-kZ","_links":{"self":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts\/1301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/comments?post=1301"}],"version-history":[{"count":2,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts\/1301\/revisions"}],"predecessor-version":[{"id":1305,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts\/1301\/revisions\/1305"}],"wp:attachment":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/media?parent=1301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/categories?post=1301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/tags?post=1301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}