{"id":103775,"date":"2020-05-20T07:00:00","date_gmt":"2020-05-20T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=103775"},"modified":"2020-05-20T06:55:09","modified_gmt":"2020-05-20T13:55:09","slug":"20200520-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20200520-00\/?p=103775","title":{"rendered":"The case of the <CODE>SHGet&shy;Folder&shy;Path(CSIDL_<WBR>COMMON_<WBR>DOCUMENTS)<\/CODE> that returned <CODE>ERROR_<WBR>PATH_<WBR>NOT_<WBR>FOUND<\/CODE>"},"content":{"rendered":"<p>A customer was experiencing a problem with the <code>SHGet\u00adFolder\u00adPath<\/code> function. Specifically, they had a program that called the function like this:<\/p>\n<pre>SHGetFolderPath(NULL, CSIDL_COMMON_DOCUMENTS, NULL,\r\n                SHGFP_TYPE_CURRENT, pathBuffer);\r\n<\/pre>\n<p>but it failed with error <code>0x80070003<\/code> which is the <code>HRESULT<\/code> version of <code>ERROR_<wbr \/>PATH_<wbr \/>NOT_<wbr \/>FOUND<\/code>. The error occurs only when run from a Jenkins pipeline. If they the run the program standalone, then the function succeeds and returns the expected result.<\/p>\n<p>A procmon trace showed that the application tried to access the folder <code>C:\\<wbr \/>Windows\\<wbr \/>SysWOW64\\<wbr \/>autobuild\\<wbr \/>Documents<\/code>, which failed with <code>NAME_<wbr \/>NOT_<wbr \/>FOUND<\/code>. And that was the clue that broke things open.<\/p>\n<p>The Common Documents folder defaults to <code>%PUBLIC%\\<wbr \/>Documents<\/code>. The <code>PUBLIC<\/code> environment variable&#8217;s normal value is <code>C:\\<wbr \/>Users\\<wbr \/>Public<\/code>, but when the program runs as part of a Jenkins pipeline, the environment variable is set to <code>autobuild<\/code> for some reason.<\/p>\n<p>This means that when the program calls <code>SHGet\u00adFolder\u00adPath<\/code> and asks for <code>CSIDL_<wbr \/>COMMON_<wbr \/>DOCUMENTS<\/code>, the system looks for <code>autobuild\\<wbr \/>Documents<\/code>, which doesn&#8217;t exist, hence error <code>0x80070003<\/code>: &#8220;The system cannot find the path specified.&#8221;<\/p>\n<p>There are a number of environment variables that have special meaning, and you change them at your peril. You probably know about variables like <code>windir<\/code>, <code>ProgramFiles<\/code>, and <code>TEMP<\/code>, but there are quite a number of other special environment variables, and <code>PUBLIC<\/code> is one of them.<\/p>\n<p>Armed with this information, the customer went back to see who was messing with the <code>PUBLIC<\/code> environment variable and try to get them to stop.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Accidentally reconfiguring the system.<\/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-103775","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Accidentally reconfiguring the system.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/103775","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=103775"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/103775\/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=103775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=103775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=103775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}