{"id":1734,"date":"2019-03-25T17:36:25","date_gmt":"2019-03-25T20:36:25","guid":{"rendered":"http:\/\/xexeu.elipse.com.br\/pt\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/"},"modified":"2020-05-06T17:43:01","modified_gmt":"2020-05-06T20:43:01","slug":"kb34941-executando-programa-externo-ao-iniciar-o-dominio","status":"publish","type":"post","link":"https:\/\/kb.elipse.com.br\/en\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/","title":{"rendered":"KB-34941: Executando programa externo ao iniciar o dom\u00ednio."},"content":{"rendered":"<div style=\"text-align: justify;\">\n<p><span style=\"font-weight: bold;\">Descri\u00e7\u00e3o:<\/span><\/p>\n<p>Como executar uma aplica\u00e7\u00e3o quando o dom\u00ednio inicia, mesmo que n\u00e3o haja um <span style=\"font-weight: bold;\">E3Viewer<\/span> aberto (ver nota ao final deste artigo)?<\/p>\n<p><span style=\"font-weight: bold;\">Solu\u00e7\u00e3o:<\/span><\/p>\n<p>Para isso, basta colocar o script abaixo no evento <span style=\"font-style: italic;\">OnStartRunning <\/span>de um Tag Interno:<\/p>\n<\/div>\n<pre><br style=\"font-family: Courier New; color: #000000;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">Set WshShell = CreateObject(\"WScript.Shell\")<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">WshShell.Run \"c:\\AppE3\\aplicativo.exe\"<\/span><\/pre>\n<div style=\"text-align: justify;\">\n<p>Deste modo, ele ser\u00e1 executado toda vez que o dom\u00ednio for iniciado.<\/p>\n<p>Por\u00e9m, para terminar este processo quando o dom\u00ednio para, \u00e9 necess\u00e1rio saber o <span style=\"font-weight: bold;\">PID <\/span>(ProcessID) que foi criado para ele ap\u00f3s ter executado o <span style=\"font-family: Courier New; color: #000000;\">WshShell.Run<\/span>. Depois de obter essa informa\u00e7\u00e3o, deve-se editar o script acima para o seguinte:<\/p>\n<\/div>\n<pre><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">WshShell.Run \"c:\\AppE3\\aplicativo.exe\"<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">ProcessName = \"aplicativo.exe\"<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">Set service = GetObject(\"winmgmts:\\\\.\\root\\cimv2\")<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">Set results = service.ExecQuery(\" Select * from Win32_Process where Name = '\"& ProcessName &\"'\")<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">if results.count <> 0 then<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">\u00a0\u00a0\u00a0\u00a0 for each obj in results<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TagInternoProcessID = obj.ProcessId<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 exit sub<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">\u00a0\u00a0\u00a0\u00a0 next<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">end if<\/span><\/pre>\n<div style=\"text-align: justify;\">Ent\u00e3o, para encerrar o <span style=\"font-weight: bold;\">PID<\/span>, deve-se criar o seguinte script no evento <span style=\"font-style: italic;\">OnStopRunning <\/span>do Tag Interno:<\/div>\n<pre><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">Set service = GetObject(\"winmgmts:\\\\.\\root\\cimv2\")<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">Set results = service.ExecQuery(\" Select * from Win32_Process where ProcessId ='\" & TagInternoProcessID & \"'\")<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">for each obj in results<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">\u00a0\u00a0\u00a0\u00a0\u00a0 obj.Terminate()<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">\u00a0\u00a0\u00a0\u00a0\u00a0 exit sub<\/span><br style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\" \/><span style=\"color: #000000; background-color: #ffffff; font-family: Courier New;\">next<\/span><\/pre>\n<div style=\"text-align: justify;\"><span style=\"font-weight: bold;\">Observa\u00e7\u00e3o:<\/span> verifique seu script, configurando as vari\u00e1veis necess\u00e1rias e links para o Tag Interno.<\/div>\n<div><\/div>\n<div style=\"text-align: justify;\"><strong>NOTA:\u00a0<\/strong>H\u00e1 uma certa restri\u00e7\u00e3o no uso do tradicional objeto\u00a0<em>Shell<\/em>\u00a0do Win XP, pois\u00a0a partir do\u00a0Windows Vista ou vers\u00f5es superiores os servi\u00e7os que rodam na conta SYSTEM (como o E3Run) n\u00e3o podem mais mostrar janelas; em outras palavras, eles n\u00e3o podem mais \u201cinteragir com o desktop\u201d. A alternativa neste caso \u00e9 inserir os scripts que rodam programas com janelas apenas em eventos do Viewer, usando o m\u00e9todo\u00a0<i>ExecuteExternalApp<\/i>, ou o pick de executar aplica\u00e7\u00e3o.\u00a0Vale lembrar que para isto\u00a0a pasta onde est\u00e1 o arquivo deve ser compartilhada na rede, para poder ser acessada das diferentes m\u00e1quinas\/viewers clientes.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Descri\u00e7\u00e3o: Como executar uma aplica\u00e7\u00e3o quando o dom\u00ednio inicia, mesmo que n\u00e3o haja um E3Viewer aberto (ver nota ao final deste artigo)? Solu\u00e7\u00e3o: Para isso, basta colocar o script abaixo&hellip;<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0},"categories":[610],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>KB-34941: Executando programa externo ao iniciar o dom\u00ednio. - Elipse Knowledgebase<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"KB-34941: Executando programa externo ao iniciar o dom\u00ednio.\" \/>\n<meta property=\"og:description\" content=\"Descri\u00e7\u00e3o: Como executar uma aplica\u00e7\u00e3o quando o dom\u00ednio inicia, mesmo que n\u00e3o haja um E3Viewer aberto (ver nota ao final deste artigo)? Solu\u00e7\u00e3o: Para isso, basta colocar o script abaixo&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/\" \/>\n<meta property=\"og:site_name\" content=\"Elipse Knowledgebase\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/elipsesoftware\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-25T20:36:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-05-06T20:43:01+00:00\" \/>\n<meta name=\"author\" content=\"Renan De Rossi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Renan De Rossi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/\"},\"author\":{\"name\":\"Renan De Rossi\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/05f0d8f49e5ffe573156b4bd742c627f\"},\"headline\":\"KB-34941: Executando programa externo ao iniciar o dom\u00ednio.\",\"datePublished\":\"2019-03-25T20:36:25+00:00\",\"dateModified\":\"2020-05-06T20:43:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/\"},\"wordCount\":254,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"articleSection\":[\"Scripts\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/\",\"url\":\"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/\",\"name\":\"[:pt]KB-34941: Executando programa externo ao iniciar o dom\u00ednio.[:] - Elipse Knowledgebase\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#website\"},\"datePublished\":\"2019-03-25T20:36:25+00:00\",\"dateModified\":\"2020-05-06T20:43:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\/\/kb.elipse.com.br\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"KB-34941: Executando programa externo ao iniciar o dom\u00ednio.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kb.elipse.com.br\/#website\",\"url\":\"https:\/\/kb.elipse.com.br\/\",\"name\":\"Elipse Knowledgebase\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kb.elipse.com.br\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\",\"name\":\"Elipse Software\",\"url\":\"https:\/\/kb.elipse.com.br\/\",\"sameAs\":[\"http:\/\/www.facebook.com\/elipsesoftware\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png\",\"contentUrl\":\"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png\",\"width\":161,\"height\":58,\"caption\":\"Elipse Software\"},\"image\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/05f0d8f49e5ffe573156b4bd742c627f\",\"name\":\"Renan De Rossi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/39b08f7b309bb6a0abb90e1f09048d80?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/39b08f7b309bb6a0abb90e1f09048d80?s=96&d=mm&r=g\",\"caption\":\"Renan De Rossi\"},\"url\":\"https:\/\/kb.elipse.com.br\/en\/author\/renan\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"KB-34941: Executando programa externo ao iniciar o dom\u00ednio. - Elipse Knowledgebase","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/","og_locale":"en_US","og_type":"article","og_title":"[:pt]KB-34941: Executando programa externo ao iniciar o dom\u00ednio.[:] - Elipse Knowledgebase","og_description":"Descri\u00e7\u00e3o: Como executar uma aplica\u00e7\u00e3o quando o dom\u00ednio inicia, mesmo que n\u00e3o haja um E3Viewer aberto (ver nota ao final deste artigo)? Solu\u00e7\u00e3o: Para isso, basta colocar o script abaixo&hellip;","og_url":"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/","og_site_name":"Elipse Knowledgebase","article_publisher":"http:\/\/www.facebook.com\/elipsesoftware","article_published_time":"2019-03-25T20:36:25+00:00","article_modified_time":"2020-05-06T20:43:01+00:00","author":"Renan De Rossi","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Renan De Rossi","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/#article","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/"},"author":{"name":"Renan De Rossi","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/05f0d8f49e5ffe573156b4bd742c627f"},"headline":"KB-34941: Executando programa externo ao iniciar o dom\u00ednio.","datePublished":"2019-03-25T20:36:25+00:00","dateModified":"2020-05-06T20:43:01+00:00","mainEntityOfPage":{"@id":"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/"},"wordCount":254,"commentCount":0,"publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"articleSection":["Scripts"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/","url":"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/","name":"[:pt]KB-34941: Executando programa externo ao iniciar o dom\u00ednio.[:] - Elipse Knowledgebase","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/#website"},"datePublished":"2019-03-25T20:36:25+00:00","dateModified":"2020-05-06T20:43:01+00:00","breadcrumb":{"@id":"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kb.elipse.com.br\/kb34941-executando-programa-externo-ao-iniciar-o-dominio\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/kb.elipse.com.br\/en\/"},{"@type":"ListItem","position":2,"name":"KB-34941: Executando programa externo ao iniciar o dom\u00ednio."}]},{"@type":"WebSite","@id":"https:\/\/kb.elipse.com.br\/#website","url":"https:\/\/kb.elipse.com.br\/","name":"Elipse Knowledgebase","description":"","publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kb.elipse.com.br\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/kb.elipse.com.br\/#organization","name":"Elipse Software","url":"https:\/\/kb.elipse.com.br\/","sameAs":["http:\/\/www.facebook.com\/elipsesoftware"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/","url":"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png","contentUrl":"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png","width":161,"height":58,"caption":"Elipse Software"},"image":{"@id":"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/05f0d8f49e5ffe573156b4bd742c627f","name":"Renan De Rossi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/39b08f7b309bb6a0abb90e1f09048d80?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/39b08f7b309bb6a0abb90e1f09048d80?s=96&d=mm&r=g","caption":"Renan De Rossi"},"url":"https:\/\/kb.elipse.com.br\/en\/author\/renan\/"}]}},"_links":{"self":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/1734"}],"collection":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/comments?post=1734"}],"version-history":[{"count":4,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/1734\/revisions"}],"predecessor-version":[{"id":10776,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/1734\/revisions\/10776"}],"wp:attachment":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/media?parent=1734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/categories?post=1734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/tags?post=1734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}