If I select multiple files of different types, why does the Open verb disappear?

Raymond Chen

Raymond

xpclient notes that if you selected multiple files of different types on Windows XP, you could still Open them all; but starting in Windows Vista, if you select multiple files of different types, then the Open verb disappears. Why is that?

Suppose you selected two files, say, a text file and a JPEG image. You right-click the multiple-file selection and pick Open. The result is that Notepad gets run to open both files. It opens the text file okay, but the JPEG image comes out a mess.

That’s because the context menu handler for a multiple-file selection is the handler for the first file in the selection. (You have to pick somebody.) Notepad can handle text files okay, but JPEG files are a bit too much.

xpclient’s example involved a selection consisting of a DOC and a DOCX file. This is a lucky break, because if you have Office installed, DOC files are of type Word.Document.8, and the handler for that is Word; meanwhile, DOCX files are of type Word.Document.12, and the handler for that also happens to be Word, so two wrongs make a right, at least in this case.

Windows Vista realized that asking Notepad to open a JPEG image was not the best outcome, so it plays it safe and decides that if the multiple-file selection contains files of multiple types, it will remove the Open verb because the handlers are in conflict; no one handler will be able to handle all the files in the selection. (Well, unless you luck out, as in xpclient’s example.)

You could argue that Windows Vista erred too much on the side of caution. It could have looked at the types and said, “Oh, the types are different. But maybe they have the same executable handler; let me look at all the verbs registered for Word.Document.8 and all the verbs registered for Word.Document.12, and for each verb, look up the handlers for each one, and if they match exactly, then allow the verb to be shown on the context menu after all.”

Coding up the logic for detecting that two handlers are distinct but equivalent would have been a lot of work for what some would consider an edge case. Minus 100 points, and possibly a science project.

Now, maybe you think that this is a common enough case, selecting multiple files that are technically different types but which coincidentally share the same handler, that the context menu handler for multiple-file selections should go to the extra work of checking each verb to see if it has the same handler for every file in the selection. (And if they don’t have the same handler, then invoke two handlers, one for each file. And if the two files have different default verbs, like how media files default to Play, but image files default to Open or Preview, then, um…) You’re right, all this could have been done. But that’s not how it ended up. Sorry.

Bonus chatter: In the case where the multiple files in the selection do not have equivalent handlers, what do you do? Maybe you invoke a separate handler for each file: Select an image file, a spreadsheet, and a word processor document, right-click them all, and select Print, and run three programs, one to print each one. Now you have to do set theory, showing a verb only if it is available in all handlers. If the user selected a thousand files, that’s a lot of handlers, and a lot of set theory, and potentially a lot of disk access. (Context menu handlers are supposed to try to avoid accessing the disk until they are invoked, but in practice they often do; for example, they may want to inspect the file contents to decide which verbs to offer.)

Things also get a bit weird if the file types have conflicting default verbs. For example, music files might default to Add to Playlist, whereas image files default to Preview. Both have an Open, though. So you get into the weird state where if you select a bunch of music files and hit Enter, then they all get added to your playlist. But if you accidentally included the album art file in your selection, then they all get Opened, and you get all the songs in your album playing simultaneously. Not sure how to fix that.

Raymond Chen
Raymond Chen

Follow Raymond   

0 comments

Comments are closed.