Explorer, registry, Visual Basic, Windows

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


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.


Windows Registry Editor Version 5.00

"Content Type"="text/plain"



Altering the “New” Explorer Menu in Windows

When you’re using Windows Explorer to set up a project skeleton for a new project the “New” context menu within Explorer can really help productivity. Being able to create blank files of the proper type can save time and aggravation. The only problem is that the “new” menu not easy to alter and the default entries are less than helpful sometimes.

The first time I looked into changing things around I searched the Windows folder looking for a simple answer. I figured there was a folder there that I could just add files to at least extend the menu, and there was. But simply dumping a file into the folder didn’t do anything. So after searching the Internet and combing through a few message boards and forums I came up with a solution.

You alter the Windows Explorer “New” menu by altering the registry. Instead of opening up regedit.exe and changing every entry, its best to use a registry script. Registry scripts are really simple scripts that alter the registry in some specific way. Comments are hash marks, keys are surrounded in brackets, and values are entered below. You remove the values under a key by preceding the key path with a minus sign. Registry scripts have the.reg file extension. Not too hard to figure out at all.

The script below is the end result. Its well commented as to make it easy for anyone to figure out and alter. The script works off of the file extension of the type of file in the menu. For example, below .txt or .html keys in HKEY_CLASSES_ROOT is the ShellNew key where you alter the values. If the ShellNew key does not exist for a particular file extension you can create it if you want to add that filetype to the menu. An empty NullValue entry below that key will create an empty file with that extension when you click it in the menu. If you want to set up a template, you can by creating one in the C:\Windows\ShellNew folder and enter a FileName value entry with the file name. This especially comes in handy when you usually create one type of HTML document all of the time and you would like to get the boilerplate code out of the way.

Save the code below (after you alter it to suit your needs) as addnewmenu.reg and double click in Windows Explorer to run (you’ll need admin rights).

Windows Registry Editor Version 5.00

# Creates and removes add-new explorer menu entries
# NullFile creates an empty file with that extension
# FileName allows you to create a template file in
#  C:\Windows\ShellNew. (use one or the other)
# Commenting both subentries and adding a minus (-)
# before the registry key (inside the brackets)
# removes it from the menu.
# Ex:
# [-HKEY_CLASSES_ROOT\.html\ShellNew]





# Get rid of the entries I don't use