{"id":98985,"date":"2018-06-12T07:00:00","date_gmt":"2018-06-12T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=98985"},"modified":"2019-03-13T00:42:05","modified_gmt":"2019-03-13T07:42:05","slug":"20180612-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20180612-00\/?p=98985","title":{"rendered":"Stupid <CODE>cmd.exe<\/CODE> tricks: Entering a directory that doesn&#8217;t exist, then immediately leaving"},"content":{"rendered":"<p>I discovered that <code>cmd.exe<\/code> lets you enter a nonexistent directory, as long as you leave it before anybody notices. <\/p>\n<pre>\nrem acts like cd C:\\Windows\ncd C:\\doesnt-exist\\..\\Windows\n\nrem acts like cd C:\\Windows\ncd C:\\really\\doesnt-exist\\..\\..\\Windows\n\nrem acts like type C:\\Windows\\win.ini\ntype C:\\doesnt-exist\\..\\Windows\\win.ini\n<\/pre>\n<p>This is handy if you have a full path to a file on the clipboard and you want to access the parent directory. For example, to <code>chdir<\/code> into the parent directory, you can type <code>cd<\/code>, a space, and then paste the full path, and then append <code>\\..<\/code> and hit <kbd>Enter<\/kbd>. <\/p>\n<pre>\nrem suppose clipboard contains C:\\directory\\with\\file.txt\nrem The next line acts like cd C:\\directory\\with\ncd C:\\directory\\with\\file.txt\\..\n<\/pre>\n<p>This trick works because <code>cmd.exe<\/code> does some path simplification before calling into the file system. It sees the <code>..<\/code> and says, &#8220;Oh, I can do that myself!&#8221; and uses it to counteract the previous directory. The previous directory is never accessed, so the command processor doesn&#8217;t notice that <i>it never existed<\/i>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s as if it never existed. Oh wait, it never existed.<\/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":[104],"class_list":["post-98985","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-tipssupport"],"acf":[],"blog_post_summary":"<p>It&#8217;s as if it never existed. Oh wait, it never existed.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/98985","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=98985"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/98985\/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=98985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=98985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=98985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}