{"id":9893,"date":"2011-08-16T07:00:00","date_gmt":"2011-08-16T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2011\/08\/16\/why-does-creating-a-shortcut-to-a-file-change-its-last-modified-time-sometimes\/"},"modified":"2011-08-16T07:00:00","modified_gmt":"2011-08-16T07:00:00","slug":"why-does-creating-a-shortcut-to-a-file-change-its-last-modified-time-sometimes","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20110816-00\/?p=9893","title":{"rendered":"Why does creating a shortcut to a file change its last-modified time&#8230; sometimes?"},"content":{"rendered":"<p>A customer observed that sometimes, the last-modified timestamp on a file would change even though nobody modified the file, or at least consciously took any steps to modify the file. In particular, they found that simply double-clicking the file in Explorer was enough to trigger the file modification.\n It took a while to puzzle out, but here&#8217;s what&#8217;s going on:\n When you double-click a file in Explorer, Explorer adds it to the Recent Items list. Internally, this is done by creating a shortcut to the item. The nice thing about a shortcut is that <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2011\/02\/24\/10133280.aspx\"> it knows how to track its target<\/a>. That way, if you move an item, then try to open it from the Recent Items list, the <a href=\"http:\/\/technet.microsoft.com\/en-us\/magazine\/2009.10.windowsconfidential.aspx\"> shortcut tracking code will try to find where you moved it to<\/a>. You moved the file. The shortcut still works. Magic.\n Shortcut target tracking magic is accomplished <a href=\"http:\/\/technet.microsoft.com\/en-us\/magazine\/2009.10.windowsconfidential.aspx\"> with the assistance of object identifiers<\/a>, and object identifiers, as we saw earlier, <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2011\/02\/28\/10134679.aspx\"> are created on demand the moment somebody first asks for one<\/a>.\n And that&#8217;s where the file modification is coming from. If the file is freshly-created, it won&#8217;t have an object identifier. When you create a shortcut to it (which happens implicitly when it is added to the Recent Items list), that triggers the creation of an object identifier, which in turn updates the last-modified time on the file.<\/p>\n<p> Frustratingly, the <i>Link&shy;Resolve&shy;Ignore&shy;Link&shy;Info<\/i> and <i>No&shy;Resolve&shy;Track<\/i> policies do not prevent the creation of object identifiers. Those policies control whether the tracking information is used during the resolve process, but they don&#8217;t control whether the tracking information is obtained during shortcut creation. (Who knows, maybe you&#8217;re creating the shortcut to be used on a machine where those policies are not in effect.) To suppress collecting the volume information and object identifier at shortcut creation time, you need to pass the <a href=\"http:\/\/msdn.microsoft.com\/bb762540.aspx\"> <code>SLDF_FORCE_NO_LINKINFO<\/code> and <code>SLDF_FORCE_NO_LINKTRACK<\/code> flags<\/a> to the <a href=\"http:\/\/msdn.microsoft.com\/bb774920.aspx\"> <code>IShell&shy;Link&shy;Data&shy;List::Set&shy;Flags<\/code><\/a> method when you create the shortcut. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A customer observed that sometimes, the last-modified timestamp on a file would change even though nobody modified the file, or at least consciously took any steps to modify the file. In particular, they found that simply double-clicking the file in Explorer was enough to trigger the file modification. It took a while to puzzle out, [&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":[104],"class_list":["post-9893","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-tipssupport"],"acf":[],"blog_post_summary":"<p>A customer observed that sometimes, the last-modified timestamp on a file would change even though nobody modified the file, or at least consciously took any steps to modify the file. In particular, they found that simply double-clicking the file in Explorer was enough to trigger the file modification. It took a while to puzzle out, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/9893","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=9893"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/9893\/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=9893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=9893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=9893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}