{"id":8828,"date":"2019-09-16T16:49:17","date_gmt":"2019-09-16T19:49:17","guid":{"rendered":"http:\/\/kb.elipse.com.br\/en\/?p=8828"},"modified":"2022-08-27T17:53:24","modified_gmt":"2022-08-27T20:53:24","slug":"kb-104311-returning-the-results-of-a-windows-script-host-wsh-script","status":"publish","type":"post","link":"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/","title":{"rendered":"KB-104311: Returning the results of a Windows Script Host (WSH) script."},"content":{"rendered":"<h2>Question:<\/h2>\n<p>How can I return the results of a WSH &#8211; Windows Script Host (<a href=\"https:\/\/docs.microsoft.com\/en-us\/previous-versions\/ms950396(v=msdn.10)\">WScript Object<\/a>) script fired via Elipse E3? For example: can I retrieve the resulting string of a command executed via Command Prompt?<\/p>\n<p><a href=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/09\/8580\/1.png\"><img loading=\"lazy\" class=\"aligncenter wp-image-8588 size-full\" src=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/09\/8580\/1.png\" alt=\"command prompt\" width=\"519\" height=\"323\" \/><\/a><\/p>\n<h2>Solution:<\/h2>\n<p>Yes, you can return the results of a WSH script fired via Elipse E3. To do so, you must first understand what the Windows Script Host is, and how it works.<\/p>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/en-us\/previous-versions\/windows\/internet-explorer\/ie-developer\/windows-scripting\/9bbdkx3k(v=vs.84)\">Windows Script Host<\/a>, also known as &#8220;WSH&#8221;, is a comprehensive script infrastructure for theMicrosoft\u00ae Windows\u00ae platform. There are two Windows Script mechanisms available for scripting: Visual Basic\u00ae Scripting Edition and Microsoft JScript\u00ae. Both these tools allow you to develop different types of scripts in order to accomplish various tasks inside the Windows environment. And since the WSH environment can be expanded, you can also use other programming languages for it, such as Python, for example.<\/p>\n<p>It also includes several automation methods that are <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/com\/using-com-objects-in-windows-script-host\" target=\"_blank\" rel=\"noopener noreferrer\">compatible<\/a> with <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/com\/the-component-object-model\">COM<\/a> platform, thus allowing you to perform taks via the <a href=\"https:\/\/docs.microsoft.com\/en-us\/previous-versions\/windows\/internet-explorer\/ie-developer\/windows-scripting\/f51wc7hz(v=vs.84)\">WSH objects<\/a> model.<\/p>\n<p><a href=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/09\/8580\/2.png\"><img loading=\"lazy\" class=\"aligncenter wp-image-8587 size-full\" src=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/09\/8580\/2.png\" alt=\"WSH script\" width=\"139\" height=\"276\" \/><\/a><\/p>\n<p>Therefore, in order to return the string that contains the executed result of the command via Elipse E3 prompt, we will create a\u00a0 <a href=\"https:\/\/docs.microsoft.com\/en-us\/previous-versions\/windows\/internet-explorer\/ie-developer\/windows-scripting\/aew9yb99%28v%3dvs.84%29\" target=\"_blank\" rel=\"noopener noreferrer\">WshShell object<\/a>, using <a href=\"https:\/\/docs.microsoft.com\/en-us\/previous-versions\/windows\/internet-explorer\/ie-developer\/windows-scripting\/ateytk4a(v=vs.84)\">Exec()<\/a> method <strong>StdOut.ReadAll<\/strong> function:<\/p>\n<pre><span class=\"\">Sub <\/span><span class=\"kw1\">CommandButton2_Click<\/span><span class=\"br0\">(<\/span><span class=\"br0\">)\r\n<\/span><span class=\"\">strCMD = <\/span><span class=\"st0\">\"Xcopy \"<\/span><span class=\"st0\">\"C:SourceDoc1.txt\"<\/span><span class=\"st0\">\" \"<\/span><span class=\"st0\">\"E:Destination\"<\/span><span class=\"st0\">\" \/Y\"\r\n<\/span><span class=\"\">Set WshShell = <\/span><span class=\"kw1\">CreateObject<\/span><span class=\"br0\">(<\/span><span class=\"st0\">\"WSCript.shell\"<\/span><span class=\"br0\">)\r\n<\/span><span class=\"\">strReturn = WshShell.<\/span><span class=\"kw1\">Exec<\/span><span class=\"br0\">(<\/span><span class=\"\">strCMD<\/span><span class=\"br0\">)<\/span><span class=\"\">.StdOut.ReadAll\r\n<\/span><span class=\"\">msgbox strReturn\r\n<\/span><span class=\"\">End Sub<\/span><\/pre>\n<p><a href=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/09\/8580\/3.png\"><img loading=\"lazy\" class=\"aligncenter wp-image-8584\" src=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/09\/8580\/3.png\" alt=\"returned result\" width=\"152\" height=\"160\" \/><\/a><\/p>\n<p><strong>Example with ping command:<\/strong><\/p>\n<p><a href=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/09\/8580\/4.png\"><img loading=\"lazy\" class=\"aligncenter wp-image-8585 size-full\" src=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/09\/8580\/4.png\" alt=\"return with ping command\" width=\"556\" height=\"305\" \/><\/a><\/p>\n<pre>Sub CommandButton1_Click()\r\nstrCMD = \"ping 192.168.8.8\" \r\nset WshShell = CreateObject(\"WScript.Shell\") \r\nstrResult = WshShell.Exec(strCMD).StdOut.ReadAll \r\nMsgBox strResult \r\nEnd Sub\r\n<\/pre>\n<p><a href=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/09\/8580\/5.png\"><img loading=\"lazy\" class=\"aligncenter wp-image-8586\" src=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/09\/8580\/5.png\" alt=\"return result wsh script\" width=\"374\" height=\"316\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question: How can I return the results of a WSH &#8211; Windows Script Host (WScript Object) script fired via Elipse E3? For example: can I retrieve the resulting string of&hellip;<\/p>\n","protected":false},"author":3,"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":[763],"tags":[899,900,901,897],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to return the results of a Windows Script Host (WSH) script.<\/title>\n<meta name=\"description\" content=\"This article shows you how to return the executed results of a Windows Script Host (WSH) script that was fired via Elipse E3.\" \/>\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\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to return the results of a Windows Script Host (WSH) script.\" \/>\n<meta property=\"og:description\" content=\"This article shows you how to return the executed results of a Windows Script Host (WSH) script that was fired via Elipse E3.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/\" \/>\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-09-16T19:49:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-27T20:53:24+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/09\/8580\/1.png\" \/>\n<meta name=\"author\" content=\"D\u00e9lio Damin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"D\u00e9lio Damin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/\"},\"author\":{\"name\":\"D\u00e9lio Damin\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/be597eff34b5f24af940a55332870778\"},\"headline\":\"KB-104311: Returning the results of a Windows Script Host (WSH) script.\",\"datePublished\":\"2019-09-16T19:49:17+00:00\",\"dateModified\":\"2022-08-27T20:53:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/\"},\"wordCount\":230,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"keywords\":[\"CMD\",\"Command Prompt\",\"Windows Script Host\",\"WSH\"],\"articleSection\":[\"Scripts\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/\",\"url\":\"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/\",\"name\":\"How to return the results of a Windows Script Host (WSH) script.\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#website\"},\"datePublished\":\"2019-09-16T19:49:17+00:00\",\"dateModified\":\"2022-08-27T20:53:24+00:00\",\"description\":\"This article shows you how to return the executed results of a Windows Script Host (WSH) script that was fired via Elipse E3.\",\"breadcrumb\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\/\/kb.elipse.com.br\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"KB-104311: Returning the results of a Windows Script Host (WSH) script.\"}]},{\"@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\/be597eff34b5f24af940a55332870778\",\"name\":\"D\u00e9lio Damin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fdf251d36430f8dd22144c3f1bc53376?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fdf251d36430f8dd22144c3f1bc53376?s=96&d=mm&r=g\",\"caption\":\"D\u00e9lio Damin\"},\"url\":\"https:\/\/kb.elipse.com.br\/en\/author\/delio\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to return the results of a Windows Script Host (WSH) script.","description":"This article shows you how to return the executed results of a Windows Script Host (WSH) script that was fired via Elipse E3.","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\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/","og_locale":"en_US","og_type":"article","og_title":"How to return the results of a Windows Script Host (WSH) script.","og_description":"This article shows you how to return the executed results of a Windows Script Host (WSH) script that was fired via Elipse E3.","og_url":"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/","og_site_name":"Elipse Knowledgebase","article_publisher":"http:\/\/www.facebook.com\/elipsesoftware","article_published_time":"2019-09-16T19:49:17+00:00","article_modified_time":"2022-08-27T20:53:24+00:00","og_image":[{"url":"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/09\/8580\/1.png"}],"author":"D\u00e9lio Damin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"D\u00e9lio Damin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/#article","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/"},"author":{"name":"D\u00e9lio Damin","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/be597eff34b5f24af940a55332870778"},"headline":"KB-104311: Returning the results of a Windows Script Host (WSH) script.","datePublished":"2019-09-16T19:49:17+00:00","dateModified":"2022-08-27T20:53:24+00:00","mainEntityOfPage":{"@id":"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/"},"wordCount":230,"commentCount":0,"publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"keywords":["CMD","Command Prompt","Windows Script Host","WSH"],"articleSection":["Scripts"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/","url":"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/","name":"How to return the results of a Windows Script Host (WSH) script.","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/#website"},"datePublished":"2019-09-16T19:49:17+00:00","dateModified":"2022-08-27T20:53:24+00:00","description":"This article shows you how to return the executed results of a Windows Script Host (WSH) script that was fired via Elipse E3.","breadcrumb":{"@id":"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kb.elipse.com.br\/en\/kb-104311-returning-the-results-of-a-windows-script-host-wsh-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/kb.elipse.com.br\/en\/"},{"@type":"ListItem","position":2,"name":"KB-104311: Returning the results of a Windows Script Host (WSH) script."}]},{"@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\/be597eff34b5f24af940a55332870778","name":"D\u00e9lio Damin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/fdf251d36430f8dd22144c3f1bc53376?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fdf251d36430f8dd22144c3f1bc53376?s=96&d=mm&r=g","caption":"D\u00e9lio Damin"},"url":"https:\/\/kb.elipse.com.br\/en\/author\/delio\/"}]}},"_links":{"self":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/8828"}],"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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/comments?post=8828"}],"version-history":[{"count":8,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/8828\/revisions"}],"predecessor-version":[{"id":13560,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/8828\/revisions\/13560"}],"wp:attachment":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/media?parent=8828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/categories?post=8828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/tags?post=8828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}