Sunday, January 15, 2017

windows 8.1 - What makes Internet Shortcut files special?

When I save a shortcut from Firefox to disk, this is its contents when viewed in a text or hex editor.



[InternetShortcut]
URL=http://superuser.com/
IDList=
HotKey=0
IconFile=C:\Users\Jerry\AppData\Local\Mozilla\Firefox\Profiles\e8oe2h15.default\shortcutCache\ndPGaHoK9RbB9Xs6pYDwiA==.ico

IconIndex=0


It appears very simple: plain text with some markup in a file.



Let's say I want to recreate this file manually.




  1. I create an empty text file.

  2. I paste the contents above into it.


  3. .. save the file and exit the program.

  4. .. change the file extension from txt to url.

  5. .. accept the risk of loosing file type association by clicking YES
    when prompted.



1



Now, I would expect to be able to open this file in my default web browser by double clicking on the file icon. But no, it doesn't work like that. Instead, I receive an error message.




2




The target "" of this Internet Shortcut is not valid. Go to the
Internet Shortcut property sheet and make sure the target is correct.




What exactly is meant by target ""?



By searching here on the site, I can see that several other users have stumbled upon this or similar difficulties with Internet Shortcut files, and some have even attempted to create "cross platform" Internet Shortcut files. What I don't see is why this is such a pain in the first place.




It's supposed to be just a simple file with a URL address that opens in a web browser. So what makes these "Internet Shortcut" files special? What makes them tick? When I compare my file with the original, they appear to be identical. So where exactly is the problem then?



Update






Here's some interesting findings. The word "target" likely means URL, and "Internet Shortcut property sheet" most probably refers to "Web Document" tab on the file properties dialog box. If I remember correctly it was titled "Internet Shortcut" in previous versions of Windows (in Windows 98 at least). It appears to have been renamed to Web Document since then.



There is more to it! As can be seen from the screenshots below, my file shares the same SHA1 digest as the original. But it does not share the same file icon, nor does it have the "Web Document" tab.




original file properties
new file properties
original file sha1
new file sha1



What's even more is that when I rename my new file so that it begins with an upper case letter, it becomes a functional Internet Shortcut file. Just like that! It just starts working. If I rename it again, so that it starts with a lower case letter, it stops working... again. Don't take my word for it, have a look at the screenshot below.



new file properties with new name




It also helps starting the file name with an underscore, a dash, a point, a parenthesis, curly brace, square bracket, equal sign, number sign, exclamation mark, and so on. It even properly replaces the globe icon with a blank paper sheet icon. Renaming it to anything other than test or Test really changes the icon.



But what's causing it to behave or misbehave like this? For instance, why would it matter if the file name begins with an upper case letter? There is no such limitation for regular files...



Update 2






If the new file's name starts with an upper case letter, prior to changing the name extension, and then gets renamed so that it starts with a lower case letter... then it still works!




So if you go about it like this, it will work:



newfile Lancelot.txt
pastein Lancelot.txt
rename Lancelot.txt Lancelot.url
rename Lancelot.url lancelot.url


a
b




Update 3






It is likely that the original problem with the test.url file occurred at step 4 above. I had initially created a file named test.txt on a different disk and renamed it test.url. This was before I created a second file with the same name on the system disk in Desktop folder (as depicted above). I do not recollect, but it is likely that I initially created a file, changed the name extension, and then pasted in the target URL and saving it and hoping for it to work by a simple double click. As opposed to creating the file, pasting in the target URL, and then changing the name extension.

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...