Preview File Types as Text in Preview Pane in Windows Explorer on Windows 10, 8, 7, and Vista

35321504842_fd27e533ef_o
Visual Basic file shown in the preview pan in Windows Explorer (file from the tutorial here)

If you use Windows the way I do you use the Windows Explorer Preview pane to look at text based files. Why? Because it’s just easier that way. Most of the time I have to look back at files to see exactly how I pulled something off in the past. If it wasn’t for the preview pane I would have to open that file up in whatever editor is associated with it. That takes more time.

Setting the preview pane to view a filetype as text is as simple as setting a couple of registry keys. The average user really shouldn’t alter the Windows Registry without knowing what they’re doing as it could render the system unusable. There’s a registry script that can be altered for any file type at the end of the post.

The new, more modern “Windows 10”, way of setting the preview pane to show a filetype as text is by setting two string subkeys on the filetype in HKEY_CLASSES_ROOT. Setting the subkeys “Content Type” to “text/plain”, and “PerceivedType” to “text” usually works for most filetypes. This worked like a charm for my “.json” problem.

However, that isn’t always the case as I found out when tried to preview a Visual Basic filetype. I just expected it to work because I have the most recent version of Visual Studio installed on my system.  So, once again, I opened up REGEDIT and looked at the “.vb” key. I discovered the two previously mentioned subkeys were already set properly.

After trolling the Internet (for too long I might add) I discovered the “old” way. There is another key that needs to be set on the filetype in the Registry. You have to add a special GUID key to the “shellex” key below the filetype and set that with another special GUID (which I assume is the GUID for the Preview Handler for text files). The old way worked for me.

The registry script is set up to set all of these keys. Yeah, the dead keys might add a teensy bit to the Registry size – so it’s opinionated. It’s better to have everything in one place than not. Do I think programmers that invent a new text based filetype for their apps should set these keys? Absolutely, if they’re not going to write a Preview Handler shell extension.

Just replace the “.vb” extension to whatever filetype you want to preview as text.

Download

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.vb]
"Content Type"="text/plain"
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.vb\shellex]

[HKEY_CLASSES_ROOT\.vb\shellex\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s