http://www.perlmonks.org?node_id=373620


in reply to Re^2: Changing Windows Shortcut Icons
in thread Changing Windows Shortcut Icons

Thanks! It appears (through some experiments on several different versions of Windows - sorry for the delay) that having the extension 'lnk' is sufficient proof that a file is indeed a shortcut file. I had thought of that but assumed (foolishly it seems) that one could re-name a shortcut without destroying the shortcutting capability. It seems that this is not the case - you can't rename a shortcut to eliminate the '.lnk' (short of editing the directory I imagine).

However: if you rename any file to add '.lnk', the file seems to be permanently changed (since you can't remove the '.lnk') to a shortcut, though it's content is retained and can still be manipulated. In this case, the shortcut properties are inaccessible which makes me think that it isn't really a shortcut after all. Now, if you use Win32::Shortcut's Save() on such a file that isn't really a shortcut, its contents are then destroyed and replaced with the guts of a standard .lnk file and it becomes a real shortcut. Just to be weirder, I tried Save() on a normal file without '.lnk', and it too had it's content replaced, but the Explorer didn't recognise it as a shortcut as the extension was not 'lnk'. I think I'll stop now! It would be better if it were simply impossible to add '.lnk' to an existing normal file.

--
I'd like to be able to assign to an luser