{"id":7023,"date":"2012-07-30T07:00:00","date_gmt":"2012-07-30T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2012\/07\/30\/why-dont-any-commands-work-after-i-run-my-batch-file-im-told-that-they-are-not-recognized-as-an-internal-or-external-command-operable-program-or-batch-file\/"},"modified":"2012-07-30T07:00:00","modified_gmt":"2012-07-30T07:00:00","slug":"why-dont-any-commands-work-after-i-run-my-batch-file-im-told-that-they-are-not-recognized-as-an-internal-or-external-command-operable-program-or-batch-file","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20120730-00\/?p=7023","title":{"rendered":"Why don&#039;t any commands work after I run my batch file? I&#039;m told that they are not recognized as an internal or external command, operable program, or batch file."},"content":{"rendered":"<p>\nI sort of forgot to celebrate CLR Week last year,\nso let&#8217;s say that CLR week is &#8220;on hiatus&#8221; until next year.\nTo fill the summertime time slot,\nI&#8217;m going to burn off a busted pilot:\nThis week is Batch File Week 2012.\nRemember, nobody actually <i>enjoys<\/i>\nbatch programming.\nIt&#8217;s just something you have to put up with\nin order to get something done.\nBatch programming is the COBOL of Windows.\n(Who knows, if people actually like Batch File Week [fat chance],\nmaybe it&#8217;ll come back as a regular series.)\n<\/p>\n<p>\nWe&#8217;ll open Batch File Week with a simple puzzle.\n<\/p>\n<p>\nA customer reported that after running their batch file,\nalmost no commands worked any more!\n<\/p>\n<pre>\nC:\\&gt; awesomebatchfile.bat\n... awesome batch file does its work ...\nC:\\&gt; reg query \"HKLM\\Software\\Clients\\Mail\" \/ve\n'reg' is not recognized as an internal or external command,\noperable program or batch file.\n<\/pre>\n<p>\n<i>Wha? Maybe I can run regedit.<\/i>\n<\/p>\n<pre>\nC:\\&gt; regedit\n'regedit' is not recognized as an internal or external command,\noperable program or batch file.\n<\/pre>\n<p>\n<i>OMG OMG OMG OMG.<\/i><\/p>\n<pre>\nC:\\&gt; notepad\n'notepad' is not recognized as an internal or external command,\noperable program or batch file.\n<\/pre>\n<p>\nOkay, first, sit down and take a deep breath.\nMaybe take a\n<a HREF=\"http:\/\/www.amazon.com\/dp\/B004VBIDD0\/?tag=tholneth-20\">Chill Pill<\/a>.\n<\/p>\n<p>\nMy first question was\n&#8220;Does <code>awesomebatchfile.bat<\/code> modify the\n<code>PATH<\/code> variable?&#8221;\n(This was, strictly speaking, a psychic debugging question,\nbut a rather obvious one.)\n<\/p>\n<p>\nThe customer replied,\n&#8220;Nope.\nHere,\nI&#8217;ll send you the whole thing.&#8221;\n<\/p>\n<p>\nAnd there it was, right there at the top of\n<code>awesomebatchfile.bat<\/code>:\n<\/p>\n<pre>\n<b>set path=C:\\awesomedir<\/b>\nif NOT \"%1\"==\"\" set path=%1\ncd \/d %path%\necho Awesomeness commencing in the %path% directory!\n...\n<\/pre>\n<p>\nThe customer figured it would be convenient to have a\nvariable called <code>path<\/code>,\nunaware that this variable has special meaning to the\ncommand interpreter.\nThe customer didn&#8217;t make the connection that their\nseemingly private variable called <code>path<\/code>\nwas connected to the system variable of the same name\n(but by convention capitalized as <code>PATH<\/code>).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I sort of forgot to celebrate CLR Week last year, so let&#8217;s say that CLR week is &#8220;on hiatus&#8221; until next year. To fill the summertime time slot, I&#8217;m going to burn off a busted pilot: This week is Batch File Week 2012. Remember, nobody actually enjoys batch programming. It&#8217;s just something you have to [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-7023","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>I sort of forgot to celebrate CLR Week last year, so let&#8217;s say that CLR week is &#8220;on hiatus&#8221; until next year. To fill the summertime time slot, I&#8217;m going to burn off a busted pilot: This week is Batch File Week 2012. Remember, nobody actually enjoys batch programming. It&#8217;s just something you have to [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/7023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=7023"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/7023\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=7023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=7023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=7023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}