{"id":5127,"date":"2014-03-30T19:03:56","date_gmt":"2014-03-30T19:03:56","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/pipe-doesnt-work-after-reg-query-collection-of-common-programming-errors\/"},"modified":"2014-03-30T19:03:56","modified_gmt":"2014-03-30T19:03:56","slug":"pipe-doesnt-work-after-reg-query-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/pipe-doesnt-work-after-reg-query-collection-of-common-programming-errors\/","title":{"rendered":"Pipe doesn&#39;t work after reg query?-Collection of common programming errors"},"content":{"rendered":"<p>Error messages are sent to Standard Error and to Standard Output hence you need to redirect Standard Error to Standard Output before running <code>find<\/code> on the output.<\/p>\n<pre><code>reg query \"HKLM\\Software\\JavaSoft\\Java Runtime Environment\" 2&gt;&amp;1 | find \"ERROR\" &gt; nul\n<\/code><\/pre>\n<p>Another thing is that reg query itself returns 0 or 1 on success or failure<\/p>\n<pre><code>Return Code: (Except for REG COMPARE)\n  0 - Successful\n  1 - Failed\n<\/code><\/pre>\n<p>So you may not have to use <code>find<\/code> at all.<\/p>\n<pre><code>reg query \"HKLM\\Software\\JavaSoft\\Java Runtime Environment\"  &gt; nul 2&gt; nul\n\nif %errorlevel% == 0  goto success\necho \"Not found\"\ngoto end\n:success\necho \"Found\"\n:end\n<\/code><\/pre>\n<p>I am just printing Found\/Not found &#8211; but you can take whatever action you want.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Error messages are sent to Standard Error and to Standard Output hence you need to redirect Standard Error to Standard Output before running find on the output. reg query &#8220;HKLM\\Software\\JavaSoft\\Java Runtime Environment&#8221; 2&gt;&amp;1 | find &#8220;ERROR&#8221; &gt; nul Another thing is that reg query itself returns 0 or 1 on success or failure Return Code: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5127","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5127"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5127\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}